Skip to content

Instantly share code, notes, and snippets.

@molcay
Last active January 16, 2020 08:47
Show Gist options
  • Save molcay/4cdaa473587ebbfe513bbb97ab7ecc17 to your computer and use it in GitHub Desktop.
Save molcay/4cdaa473587ebbfe513bbb97ab7ecc17 to your computer and use it in GitHub Desktop.

Q 1: A program that gets the input and returns the output.

Input 1

data = {
    "x": {
        "w": 5,
    },
    "x/y": {
        "a": 3,
    },
    "x/y/z": 5,
    "x/t/w/b": 6,
    "x/t/w": {
        "a": 7,
    },
}

Output 1

{
  "x": {
    "w": 5,
    "y": {
      "a": 3,
      "z": 5
    },
    "t": {
      "w": {
        "a": 7
      }
    }
  }
}

Input 2

{
  "a": 3,
  "e/b.c/d": true,
  "e/b.c/e": 1,
  "b/a": {
    "c": 6,
    "pi": 3.14
  },
  "b/a/c": "value for c of a of b"
}

Output 2

{
  "a": 3,
  "e": {
    "b.c": {
      "d": true,
      "e": 1
    }
  },
  "b": {
    "a": {
      "c": "value for c of a of b",
      "pi": 3.14
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment