Skip to main content
7 of 8
added 12 characters in body
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Python, with num2words, 97 113 115 94 93 bytes

+16 bytes (forgot the hyphenation that num2words applies which does not actually change the results of any of the test cases, even though 23 and 577 each have a hyphen)
+2 bytes (forgot to include f= although recursive)
-20 bytes (use re)
-8 bytes thanks to @Wheat Wizard (use ~, replace n!=4 with n-4, and ...one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n-4 and-~f(len(re.sub('\W|and','',w.num2words(n)))) 

Just counts up the number of steps, returns False for 0, but works for huge and negative integers too (\W finds the spaces, commas and hyphens in the num2words result):

>>> for test in (1,4,7,23,577,600,-1*2**96,3**96): ... print('test: {0} -> {1}'.format(test, f(test))) ... test: 1 -> 3 test: 4 -> False test: 7 -> 2 test: 23 -> 5 test: 577 -> 6 test: 600 -> 4 test: -79228162514264337593543950336 -> 4 test: 6362685441135942358474828762538534230890216321 -> 5 

Here is that last case, step by step:

sixquattuordecillionthreehundredsixtytwotredecillionsixhundredeightyfiveduodecillionfourhundredfortyoneundecilliononehundredthirtyfivedecillionninehundredfortytwononillionthreehundredfiftyeightoctillionfourhundredseventyfourseptillioneighthundredtwentyeightsextillionsevenhundredsixtytwoquintillionfivehundredthirtyeightquadrillionfivehundredthirtyfourtrilliontwohundredthirtybillioneighthundredninetymilliontwohundredsixteenthousthreehundredtwentyone fourhundredfiftyone nineteen eight five 
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293