Z16920

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z16920"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z16919",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z16919(Z16919K1):\r\n    units = [\"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\"]\r\n    teens = [\"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\"]\r\n    tens = [\"ten\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\r\n    #add more orders if you want \r\n    scales = [\"thousand\", \"million\", \"billion\", \"trillion\",\"quadrillion\",\"quintillion\",\"sextillion\",\"septillion\",\"octillion\",\"nonillion\",\"decillion\",\"undecillion\"]\r\n\r\n    units_dict = {word: i for i, word in enumerate(units)}\r\n    teens_dict = {word: 10 + i for i, word in enumerate(teens, 1)}\r\n    tens_dict = {word: 10 * (i + 1) for i, word in enumerate(tens)}\r\n    scales_dict = {word: 10 ** (3 * (i + 1)) for i, word in enumerate(scales)}\r\n\r\n    def parse_words(words_list):\r\n        current = result = 0\r\n        for word in words_list:\r\n            if word in units_dict:\r\n                current += units_dict[word]\r\n            elif word in teens_dict:\r\n                current += teens_dict[word]\r\n            elif word in tens_dict:\r\n                current += tens_dict[word]\r\n            elif word == \"hundred\":\r\n                current *= 100\r\n            elif word in scales_dict:\r\n                result += current * scales_dict[word]\r\n                current = 0\r\n            elif word == \"and\":\r\n                continue\r\n            else: #case when the input contains an unexpected word\r\n                return -1\r\n        return result + current\r\n\r\n    words_list = Z16919K1.lower().strip().replace('-', ' ').replace(',', ' ').split()\r\n    return parse_words(words_list)\r\n"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "English natural number transcription, python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1004",
                "Z11K2": "cardinal en anglais vers nombre naturel, en Python"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Englische Zahl in natürliche Zahl in Python"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "This implementation works up to hundreds of undecillion"
            },
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1430",
                "Z11K2": "Implementierung für Zahlen bis zu Hunderten von Sextillionen"
            }
        ]
    }
}