puzzles/funky/funky.py
Zoé Cassiopée Gauthier 7e4f02547b Initial commit
2024-04-02 17:01:09 -04:00

56 lines
1.1 KiB
Python

import os
def words(n):
if n >= 1000:
return words(n // 1000) + " thousand " + words(n % 1000)
elif n >= 100:
return words(n // 100) + " hundred " + words(n % 100)
elif n >= 20:
tens = [
"twenty",
"thirty",
"fourty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety",
][n // 10 - 2]
if n % 10 == 0:
return tens
else:
return tens + "-" + words(n % 10)
else:
return [
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
][n]
def main():
size = os.stat(__file__).st_size
print(words(size))
if __name__ == "__main__":
main()