Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Challenge] Dictionary Decompression #54

Closed
ericwburden opened this issue Apr 30, 2021 · 2 comments
Closed

[Challenge] Dictionary Decompression #54

ericwburden opened this issue Apr 30, 2021 · 2 comments
Labels
proposed challenge An idea for a future challenge

Comments

@ericwburden
Copy link
Collaborator

Dictionary Decompression

Given a nested dictionary, flatten the dictionary such that the keys of the final result are namespaced with a period between the original keys leading to the value.

Business Rules/Errata

  • Data Structure Required: Dictionary/Map/HashMap This challenge requires a language that supports a version of a Dictionary.
  • Your function should be able to flatten dictionaries nested arbitrarily deeply.
  • You can assume that none of the dictionary keys contain a period.
  • The type of the dictionary values is not important to this exercise. Assume they will always be unsigned integers.

Example

nested_dict = {
  "key": 3,
  "foo": {
    "a": 5,
    "bar": {
      "baz": 8
    }
  }
}

result = flattenDictionary(nested_dict)
print(result)

{
  "key": 3,
  "foo.a": 5,
  "foo.bar.baz": 8
}
@ericwburden ericwburden added the proposed challenge An idea for a future challenge label Apr 30, 2021
@xanderyzwich
Copy link
Collaborator

I really like this one. It will likely involve really shallow recursion.

@xanderyzwich
Copy link
Collaborator

closed by #82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposed challenge An idea for a future challenge
Projects
None yet
Development

No branches or pull requests

2 participants