Z26232

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z26232"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z26121",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z610",
            "Z16K2": "def Z26121(Z26121K1):\n\t# Copied from Z24625, removed the ten's powers over million\n\tdef cardinal(Z24618K1):\n\t\tnumber = Z24618K1\n\t\tzero = \"нула\"\n\t\tones_alt = [\"\", \"једна\", \"две\", \"три\", \"четири\", \"пет\", \"шест\", \"седам\", \"осам\", \"девет\"]\n\t\tones = [\"\", \"један\", \"два\", \"три\", \"четири\", \"пет\", \"шест\", \"седам\", \"осам\", \"девет\"]\n\t\tteens = [\"\", \"једанаест\", \"дванаест\", \"тринаест\", \"четрнаест\", \"петнаест\", \"шеснаест\", \"седамнаест\", \"осамнаест\", \"деветнаест\"]\n\t\ttens = [\"\", \"десет\", \"двадесет\", \"тридесет\", \"четрдесет\", \"педесет\", \"шездесет\", \"седамдесет\", \"осамдесет\", \"деведесет\"]\n\t\thundreds = [\"\", \"сто\", \"двеста\", \"триста\", \"четиристо\", \"петсто\", \"шестсто\", \"седамсто\", \"осамсто\", \"деветсто\"]\n\t\tblocks = [\"\", \"хиљаду\", \"хиљаде\", \"хиљада\"],\n\t\t\t\t\t\"\", \"милион\", \"милионa\", \"милиона\"\n\t\n\t\n\t\tdef join_spellings(spelling1, spelling2):\n\t\t\tif (spelling1 == \"\" or spelling2 == \"\"):\n\t\t\t\treturn spelling1 + spelling2\n\t\t\telse:\n\t\t\t\treturn spelling1 + \" \" + spelling2\n\t\t\n\t\tdef spell_block(block, use_alt):\n\t\t\thundreds_spelling = hundreds[block // 100]\n\t\t\ttens_and_ones_spelling = \"\"\n\t\t\t\n\t\t\tif 10 \u003C (block % 100) \u003C 20:\n\t\t\t\ttens_and_ones_spelling = teens[block % 10]\n\t\t\telse:\n\t\t\t\ttens_spelling = tens[(block % 100) // 10]\n\t\t\t\tones_spelling = ones_alt[block % 10] if use_alt else ones[block % 10]\n\t\t\t\ttens_and_ones_spelling = join_spellings(tens_spelling, ones_spelling)\n\t\t\t\t\t\n\t\t\treturn join_spellings(hundreds_spelling, tens_and_ones_spelling)\n\t\t\n\t\tif number == 0:\n\t\t\treturn zero\n\t\t\t\n\t\tnumber_spelling = \"\"\n\t\tnumber_remainder = number\n\t\tblock_count = 0\n\t\twhile number_remainder != 0:\n\t\t\tcurrent_block = number_remainder % 1000\n\t\t\tlast_digit = current_block % 10\n\t\t\tlast_two_digits = current_block % 100\n\t\t\tblock_spelling = spell_block(current_block, (block_count == 1 or block_count == 3))\n\t\t\tnumber_remainder = number_remainder // 1000\n\t\t\t\n\t\t\tif (block_spelling != \"\"):\n\t\t\t\tgrammatical_number = -1\n\t\t\t\tif last_digit == 1 and last_two_digits != 11:\n\t\t\t\t\tgrammatical_number = 1\n\t\t\t\telif (2 \u003C= last_digit \u003C= 4) and not (12 \u003C= last_two_digits \u003C= 14):\n\t\t\t\t\tgrammatical_number = 2\n\t\t\t\telse:\n\t\t\t\t\tgrammatical_number = 3\n\t\t\t\t\t\n\t\t\t\tif (block_count == 1 or block_count == 3):\n\t\t\t\t\tif current_block == 1:\n\t\t\t\t\t\tblock_spelling = \"\"\n\t\t\t\t\telif grammatical_number == 1:\n\t\t\t\t\t\tgrammatical_number = 3\n\t\n\t\t\t\tif (1 \u003C= block_count \u003C= 6):\n\t\t\t\t\tblock_spelling = join_spellings(block_spelling, blocks[block_count-1][grammatical_number])\n\t\t\t\tnumber_spelling = join_spellings(block_spelling, number_spelling)\n\t\t\t\n\t\t\tblock_count += 1\n\t\treturn number_spelling\n\t\n\tadd_i = ['пет', 'шест', 'девет', 'десет', 'једанаест', 'дванаест', 'тринаест', 'четрнаест', 'петнаест', 'шеснаест', 'седамнаест', 'осамнаест', 'деветнаест', 'двадесет', 'тридесет', 'четрдесет', 'педесет', 'шездесет', 'седамдесет', 'осамдесет', 'деведесет']\n\tadd_ti = ['сто', 'четиристо', 'петсто', 'шестсто', 'седамсто', 'осамсто', 'деветсто']\n\tordinals = {\n\t\t'један': 'први',\n\t\t'два': 'други',\n\t\t'три': 'трећи',\n\t\t'четири': 'четврти',\n\t\t'седам': 'седми',\n\t\t'осам': 'осми',\n\t\t'двеста': 'двестоти',\n\t\t'триста': 'тристоти',\n\t\t'хиљаду': 'хиљадити',\n\t\t'хиљаде': 'хиљадити',\n\t\t'хиљада': 'хиљадити',\n\t\t'милион': 'милионити',\n\t\t'милиона': 'милионити'\n\t}\n\n\tif Z26121K1 == 0:\n\t\treturn 'нулти'\n\n\tcardinal = cardinal(Z26121K1)\t# Replace with Z24618 call if it becomes possible\n\tlastword = cardinal.split(' ')[-1]\n\t\n\tif lastword in add_i:\n\t\treturn cardinal+'и'\n\telif lastword in add_ti:\n\t\treturn cardinal+'ти'\n\telif cardinal.endswith(\"један милион\"):\n\t\tresult = cardinal.split(' ')[:-2]\n\t\tresult.append(\"милионити\")\n\t\treturn ' '.join(result)\n\telif cardinal.endswith(\"два милиона\"):\n\t\tresult = cardinal.split(' ')[:-2]\n\t\tresult.extend([\"две\", \"милионити\"])\n\t\treturn ' '.join(result)\n\telif lastword in ordinals:\n\t\tresult = cardinal.split(' ')[:-1]\n\t\tresult.append(ordinals[lastword])\n\t\treturn ' '.join(result)\n\telse:\n\t\traise Exception"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "serbian ordinal, py"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "returns the ordinal number for the given natural number up to a billion"
            }
        ]
    }
}