fork download
  1. def opt_str(char, acc):
  2. opts = []
  3. char_num = ord(char)
  4. opts.append(str(char_num))
  5. if 0 < char_num - acc < 10:
  6. opts.append('+' + str(char_num - acc))
  7. if 0 < acc - char_num < 10:
  8. opts.append('-' + str(acc - char_num))
  9. if char_num - acc == 1:
  10. opts.append('^')
  11. if acc - char_num == 1:
  12. opts.append('v')
  13. if acc == char_num:
  14. opts.append('')
  15. if acc and char_num % acc == 0:
  16. opts.append('*' + str(char_num//acc))
  17. try:
  18. if acc // (acc // char_num) == char_num:
  19. opts.append('/' + str(acc // char_num))
  20. except:
  21. pass
  22. return [opt for opt in opts if len(opt) == len(min(opts, key=len))]
  23.  
  24. acc = 0
  25. result = []
  26. pos = 0
  27.  
  28. in_str = """zero
  29. one
  30. two
  31. three
  32. four
  33. five
  34. six
  35. seven
  36. eight
  37. nine
  38. ten
  39. eleven
  40. twelve
  41. thirteen
  42. fourteen
  43. fifteen
  44. sixteen
  45. seventeen
  46. eighteen
  47. nineteen
  48. twenty
  49. one and twenty
  50. two and twenty
  51. three and twenty
  52. four and twenty
  53. five and twenty
  54. six and twenty
  55. seven and twenty
  56. eight and twenty
  57. nine and twenty
  58. thirty
  59. one and thirty
  60. two and thirty
  61. three and thirty
  62. four and thirty
  63. five and thirty
  64. six and thirty
  65. seven and thirty
  66. eight and thirty
  67. nine and thirty
  68. forty
  69. one and forty
  70. two and forty
  71. three and forty
  72. four and forty
  73. five and forty
  74. six and forty
  75. seven and forty
  76. eight and forty
  77. nine and forty
  78. half third times twenty
  79. one and half third times twenty
  80. two and half third times twenty
  81. three and half third times twenty
  82. four and half third times twenty
  83. five and half third times twenty
  84. six and half third times twenty
  85. seven and half third times twenty
  86. eight and half third times twenty
  87. nine and half third times twenty
  88. three times twenty
  89. one and three times twenty
  90. two and three times twenty
  91. three and three times twenty
  92. four and three times twenty
  93. five and three times twenty
  94. six and three times twenty
  95. seven and three times twenty
  96. eight and three times twenty
  97. nine and three times twenty
  98. half fourth times twenty
  99. one and half fourth times twenty
  100. two and half fourth times twenty
  101. three and half fourth times twenty
  102. four and half fourth times twenty
  103. five and half fourth times twenty
  104. six and half fourth times twenty
  105. seven and half fourth times twenty
  106. eight and half fourth times twenty
  107. nine and half fourth times twenty
  108. four times twenty
  109. one and four times twenty
  110. two and four times twenty
  111. three and four times twenty
  112. four and four times twenty
  113. five and four times twenty
  114. six and four times twenty
  115. seven and four times twenty
  116. eight and four times twenty
  117. nine and four times twenty
  118. half fifth times twenty
  119. one and half fifth times twenty
  120. two and half fifth times twenty
  121. three and half fifth times twenty
  122. four and half fifth times twenty
  123. five and half fifth times twenty
  124. six and half fifth times twenty
  125. seven and half fifth times twenty
  126. eight and half fifth times twenty
  127. nine and half fifth times twenty
  128. one hundred"""
  129.  
  130. while pos < len(in_str):
  131. i = in_str[pos]
  132. pos += 1
  133. if i in '0123456789':
  134. if i != '0':
  135. while pos < len(in_str) and in_str[pos] in '0123456789':
  136. i += in_str[pos]
  137. pos += 1
  138. if i == str(acc):
  139. result.append('o')
  140. else:
  141. result.append(i + 'o')
  142. acc = int(i)
  143. else:
  144. opts = opt_str(i, acc)
  145. result.append(opts[0] + 'a')
  146. acc = ord(i)
  147. print(len(''.join(result)))
  148. print(''.join(result))
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
7028
122a101a114a-3a10a111ava-9a10a116a+3a-8a10a116a104a114a101aa10a102a+9a+6a-3a10a102a+3a118a101a10a115a105a120a10a115a101a118a101a+9a10a101a+4a-2a^a116a10a110a-5a+5a-9a10a116a101a+9a10a101a+7a-7a118a101a+9a10a116a+3a101a+7a118a101a10a116a104a^a+9a+2a101aa+9a10a102a+9a+6a-3a+2a101aa+9a10a102a+3a-3a116a101aa+9a10a115a105a120a-4a101aa+9a10a115a101a118a101a+9a+6a101aa+9a10a101a+4a-2a^a116a101aa+9a10a110a-5a+5a-9a116a101aa+9a10a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a^a+9a+2a+5a10a111ava-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a+3a-8a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a104a114a101aa32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+3a118a101a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a105a120a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a^a+9a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a^a+9a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+3a+2a+5a10a111ava-9a32a97a110a100a32a102a+9a+3a+2a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+3a+2a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+3a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+3a+2a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+3a+2a+5a10a115a105a120a32a97a110a100a32a102a+9a+3a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+3a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+3a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+3a+2a+5a10a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a104a117a-7a100a114a101ava