Skip to content

Instantly share code, notes, and snippets.

View yogaxpto's full-sized avatar
🏠
Working from home

Diogo yogaxpto

🏠
Working from home
View GitHub Profile
@yogaxpto
yogaxpto / main.py
Last active December 13, 2022 16:25
Viz.ai live code challenge
input_: str = """Certainly an Englishman, it was more doubtful whether Phileas Fogg was a Londoner. He was never seen on ’Change, nor at the Bank, nor in the counting-rooms of the “City”; no ships ever came into London docks of which he was the owner; he had no public employment; he had never been entered at any of the Inns of Court, either at the Temple, or Lincoln’s Inn, or Gray’s Inn; nor had his voice ever resounded in the Court of Chancery, or in the Exchequer, or the Queen’s Bench, or the Ecclesiastical Co"""
def reverse(string: str) -> str:
if len(string) <= 1:
return string
return string[-1] + reverse(string[:-1])
def occurrences(string: str) -> dict[str, int]:

Task 1:

Given an input as json array (each element is a flat dictionary) write a program that will parse this json, and return a nested dictionary of dictionaries of arrays, with keys specified in command line arguments and the leaf values as arrays of flat dictionaries matching appropriate groups

python nest.py nesting_level_1 nesting_level_2 … nesting_level_n

Example input for json can be found here: http://jsonformatter.org/74f158

When invoked like this: cat input.json | python nest.py currency country city