Z23169

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z23169"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z23003",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z23003(Z23003K1):\n    def _Z23003(Z23003K1):\n        ones = [\"\", \"uno\", \"due\", \"tre\", \"quattro\", \"cinque\", \"sei\", \"sette\", \"otto\", \"nove\", \"dieci\", \"undici\", \"dodici\", \"tredici\", \"quattordici\", \"quindici\", \"sedici\", \"diciassette\", \"diciotto\", \"diciannove\", ]\n        tens = [\"\", \"\", \"venti\", \"trenta\", \"quaranta\", \"cinquanta\", \"sessanta\", \"settanta\", \"ottanta\", \"novanta\"]\n        hundreds = [\"\", \"cento\", \"duecento\", \"trecento\", \"quattrocento\", \"cinquecento\", \"seicento\", \"settecento\", \"ottocento\", \"novecento\"]\n        units = [(\"miliardo\", 10**9), (\"milione\", 10 ** 6), (\"mila\", 10**3), (\"\", 1)]\n\n        def blend_tens_ones(tens_u,ones_u,withAccent,forceAccent=False):\n            if ones_u in (1,8):     # if ones start with a vowel\n                return tens[tens_u][:-1]+ones[ones_u]\n            if ones_u==0:\n                return tens[tens_u]\n            if ones_u==3 and withAccent and (forceAccent or tens_u\u003E0):\n                return tens[tens_u]+\"tré\"\n            return tens[tens_u]+ones[ones_u]\n\n        # function to convert numbers less than 1_000 to words\n        def words(Z23003K1, withAccent=True, forceAccent=False):\n            if Z23003K1 \u003C 20:\n                if withAccent and forceAccent and Z23003K1==3:\n                    return \"tré\"\n                return ones[Z23003K1]\n            elif Z23003K1 \u003C 100:\n                return blend_tens_ones(Z23003K1 // 10, Z23003K1 % 10, withAccent, forceAccent)\n            else:\n                hundreds_unit = hundreds[Z23003K1 // 100]\n                if Z23003K1 % 100 == 0:\n                    return hundreds_unit\n                if Z23003K1 % 100 \u003C 10:\n                    return hundreds_unit + \"e\" + words(Z23003K1 % 100, withAccent,True)\n                return hundreds_unit  + words(Z23003K1 % 100,withAccent)\n\n        # convert numbers to words\n        if Z23003K1 == 0:\n            return \"zero\"\n        elif Z23003K1 \u003C 0:\n            return \"meno \" + _Z23003(-Z23003K1)\n\n        result = \"\"\n\n        firstIteration=True\n        hasFactor1000=False\n\n        if Z23003K1\u003E=10**12:\n            count, Z23003K1 = divmod(Z23003K1, 10**9)\n            result += \" \" + _Z23003(count) + (\" miliardi\" if count%(10**6) else \" di miliardi\")\n            firstIteration=False\n\n\n\n        for unit_name, factor in units:\n            count, Z23003K1 = divmod(Z23003K1, factor)\n            # units are 1_000 times each other\n            if count \u003E 999:\n                # ERROR: number is too large for this algorithm\n                return \"ERROR: number is too large for this algorithm\"\n            prefix = words(count, factor!=10**3, factor==1 and hasFactor1000)\n\n            if factor == 10**3:\n                hasFactor1000= not (count==0)\n                if (count==1):\n                    result += \"mille\" if firstIteration else \" e mille\"\n                if count\u003E1:\n                    result+= \" \" + prefix + \"mila\" if firstIteration else \" e \" + prefix + \"mila\"\n\n            elif factor != 1:\n                # plural for milione, miliardo, ... etc\n                unit_name = (unit_name[:-1] + \"i\") if count \u003E 1 else unit_name\n                # # drop -o in uno and ventuno before units\n                if count % 10 == 1 and count % 100 != 11:\n                    prefix = prefix[:-1]\n                if count \u003E 0:\n                    result = result + \" \" + prefix + \" \" + unit_name\n\n            else:\n                # if 0\u003Ccount\u003C100:\n                #     result+= prefix # if firstIteration else \" e \" + prefix\n                # else:\n                if count\u003E0:\n                    result+= prefix if hasFactor1000 or firstIteration else  \" e \" + prefix\n                # result+= \" \" + prefix\n\n            if count\u003E0:\n                firstIteration=False\n        return result.strip()\n\n    return _Z23003(Z23003K1)\n    "
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Italian cardinal, python debug"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}