Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/number-names/oracle.py # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / number-names / oracle.py` 28 lines ยท 1206 bytes Raw Blame History 1 # Independent reference for "Number names" (Python 3, standard library only). 2 # expected.txt is this program's stdout; omc never produced it. 3 ONES = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] 4 TENS = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] 5 SCALES = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion"] 6 def below_1000(n): 7 parts = [] 8 if n >= 100: 9 parts.append(ONES[n // 100] + " hundred") 10 r = n % 100 11 if 0 < r < 20: 12 parts.append(ONES[r]) 13 elif r >= 20: 14 parts.append(TENS[r // 10 - 2] + ("-" + ONES[r % 10] if r % 10 else "")) 15 return " ".join(parts) 16 def spell(n): 17 if n == 0: 18 return "zero" 19 groups = [] 20 i = 0 21 while n: 22 n, g = divmod(n, 1000) 23 if g: 24 groups.append(below_1000(g) + (" " + SCALES[i] if i else "")) 25 i += 1 26 return " ".join(reversed(groups)) 27 for n in [0, 7, 13, 21, 99, 100, 101, 999, 1000, 1001, 12345, `1000000`, `1234567890`, `18446744073709551615`]: 28 print(f"{n}: {spell(n)}")