Skip to main content
added 16 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Python, with num2words, 97 113 115 94 93 9392 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 >_<)
-1 byte thanks to @Cyoce (space from 4 and)

<! language: lang-python -->

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

Just counts up the number of steps, returns False for 0, butsteps; 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 -> False0 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 

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 

Python, with num2words, 97 113 115 94 93 92 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 >_<)
-1 byte thanks to @Cyoce (space from 4 and)

<! language: lang-python -->

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

Just counts up the number of steps; 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 -> 0 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 
added 12 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Python, with num2words, 97 113 115 94 9493 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)
-78 bytes thanks to @Wheat Wizard (replaceuse ~, replace n!=4 with n-4, and ...one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n-4 and 1+f-~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 

Python, with num2words, 97 113 115 94 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)
-7 bytes thanks to @Wheat Wizard (replace n!=4 with n-4 and ...one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n-4 and 1+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 

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 
added 34 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Python, with num2words, 97 113 115 9594 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) 
-67 bytes thanks to @Wheat Wizard (replace n!=4 with n-4 and ...one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n!=4-4 and 1+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 

Python, with num2words, 97 113 115 95 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) -6 bytes thanks to @Wheat Wizard (one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n!=4 and 1+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 

Python, with num2words, 97 113 115 94 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) 
-7 bytes thanks to @Wheat Wizard (replace n!=4 with n-4 and ...one line import >_<)

<! language: lang-python -->

import re,num2words as w f=lambda n:n-4 and 1+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 
added 76 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading
added 76 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading
added 76 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading
added 194 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading