Count up by Syllables

5

1

Backstory

I've always found it quite annoying how some numbers in English don't have the same number of syllables even though they have the same number of digits. Example: seven has 2 syllables whereas all of the other digits have one (other than zero).

So, when I'm counting in time to something (like a drill cadence in cadets or in the military), it doesn't sound as nice because you have a random extra syllable.

But I appear to have found a solution to this!

Instead of counting the regular way, we omit the number eight. That way, the second syllable of seven carries into where eight would have been. So, we get the following:

1     2     3     4     5     6     7     8     9     10
one   two   three four  five  six   se   -  ven nine  ten

But, it's hard to count this way for higher numbers, so I need your help to make a program to help me figure out which numbers to count!

Challenge Details

Input

Input will be given as a single positive integer. For the purposes of this challenge, you may assume that all numbers are less than or equal to 999 999 999 999 999 (1 quadrillion - 1) This is because "quadrillion" has a different number of syllables than "million", "billion", and "trillion", and I needed to specify an upper bound somewhere. Since as @HelkaHomba pointed out most languages have a cap at 2^32 which is somewhere around 4 billion, you can use your language's integer bound as the limit (this must be at least 1 million to be considered valid).

Output

Output will be given as a list of integers (to be specified below). The exact formatting will not be specified, but as long as it is easy to see what the list is and it does not contain arbitrary numbers everywhere, it is pretty flexible.

What's in the list

Pretty much, starting from i = 1, append i to the list. Then, take the number of syllables in i (let this be s) and omit the next s - 1 numbers. Keep doing this until i > n where n is the input.

For the purposes of this challenge, assume that the word and is never present (so 101 is one hundred one).

Test Cases

Input -> Output
10 -> 1 2 3 4 5 6 7 9 10
7 -> 1 2 3 4 5 6 7
8 -> 1 2 3 4 5 6 7
25 -> 1 2 3 4 5 6 7 9 10 11 14 16 18 20 22 25

Additionally, since I need to be able to carry this around on a cue card when counting things in time, your program needs to be as short as possible (in bytes)!

HyperNeutrino

Posted 2017-04-09T03:45:18.583

Reputation: 26 575

Is the quadrillion limit required for language's whose usual integer maximum is 2^32 (~4 billion)? – Calvin's Hobbies – 2017-04-09T03:59:22.460

@HelkaHomba Okay, so apparently 2^32 is a lot smaller than I thought it was. No, I will say that the limit is whatever your language can handle (must be at least 1 million) or 1 quadrillion - 1, whichever is higher. Thanks. – HyperNeutrino – 2017-04-09T04:00:33.823

Answers

1

Mathematica, 117 bytes

For[t=1,t<=#,t+=Length[Join@@(#~WordData~"Hyphenation"&/@StringSplit[Echo@t~IntegerName~"Words",{"‐",", "," "}])]]&

Pure function taking a nonnegative integer as input; it echoes the appropriate integers to the standard output one at a time.

There might well be a shorter implementation in Mathematica, but this is the lazy one :) t~IntegerName~"Words" gives the English name of the integer t; then StringSplit[...,{"‐",", "," "}] divides this name into a list of individual words. (Mathematically annoyingly uses the 3-byte character (U+2010) for the hyphen in names of integers.) #~WordData~"Hyphenation"&/@ splits each of those words into a list of its syllables, and Length[Join@@(...)] counts these syllables.

Thus the function, after initializing t=1, loops as long as t doesn't exceed the input; each time, it prints t and then augments it by the number of syllables in the English name of t. In principle, this algorithm works up to 1036–1, at which point the hyphenation dictionary doesn't have an entry for "undecillion".

Greg Martin

Posted 2017-04-09T03:45:18.583

Reputation: 13 940

Nice answer! I was sort of expecting a Mathematica answer with some sort of syllable counting built in... :P – HyperNeutrino – 2017-04-09T13:52:52.927

That's one thing I like about being on this site: it makes me discover things about Mathematica that I never knew before! – Greg Martin – 2017-04-09T17:39:13.260

Certainly! I've learned a lot about various languages and I've never even used them before! – HyperNeutrino – 2017-04-09T18:18:10.250