## 4Ever

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Raymond is good at sequences. He has made a puzzle that no one in his class could solve. It involves taking a number, finding the number of letters it has, then making this number the new number, and doing this over and over again to form a sequence. Raymond found that he would always end up repeating forever at the number , because it has 4 letters, four. He showed some sample sequences to get , but none of his classmates could solve the puzzle. He is exhausted from having to count out new patterns, so he gives the task to you. You must write a program to display the sequence from an input to 4.

#### Numbers

You will use the following spellings:

1 = one     11 = eleven      30 = thirty           1000 = onethousand
2 = two     12 = twelve      40 = forty            1090 = onethousandninety
3 = three   13 = thirteen    50 = fifty            2500 = twothousandfivehundred
4 = four    14 = fourteen    60 = sixty            5123 = fivethousandonehundredtwentythree
5 = five    15 = fifteen     70 = seventy          10 000 = tenthousand
6 = six     16 = sixteen     80 = eighty           100 000 = onehundredthousand
7 = seven   17 = seventeen   90 = ninety           1 000 000 = onemillion
8 = eight   18 = eighteen    100 = onehundred      10 000 000 = tenmillion
9 = nine    19 = nineteen    101 = onehundredone   100 000 000 = onehundredmillion
10 = ten    20 = twenty      200 = twohundred      1 000 000 000 = onebillion

Note: There are no spaces.

#### Input Specification

The input will consist of an integer , the number to start the sequence.

#### Output Specification

Output one integer on each line the sequence from (exclusive) to (inclusive).

Note: Do not prompt for input, as this will cause the judge to take the prompt as the solution.

#### Sample Input 1

6

#### Sample Output 1

3
5
4

#### Explanation for Sample Output 1

is spelled as six, which has 3 letters, so the next number will be . is spelled as three, which has 5 letters, so the next number will be . is spelled as five, which has 4 letters, so the next number will be . Once is reached, the sequence is over.

#### Sample Input 2

101

#### Sample Output 2

13
8
5
4

#### Explanation for Sample Output 2

is spelled as onehundredone, which has 13 letters, so the next number will be . is spelled as thirteen, which has 8 letters, so the next number will be . is spelled as eight, which has 5 letters, so the next number will be . is spelled as five, which has 4 letters, so the next number will be . Once is reached, the sequence is over.

• commented on May 24, 2020, 1:15 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on May 24, 2020, 5:36 p.m.

why would it suddenly change when it reaches the millions?

• commented on April 23, 2020, 1:00 p.m. edited

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 24, 2020, 9:27 a.m.

It's telling me that a bunch of my answers are wrong when they should be right. for example, it told me that this output was wrong:

75 11 6 3 5 4

But if you count it up, seventyfive is 11 letters, eleven is 6 letters, six is 3, three is 5 and five is 4. So this is a correct answer.

What am I doing wrong that's making it return as a wrong answer?

• commented on May 8, 2020, 2:36 p.m.

new line in between each number.

• commented on Jan. 25, 2020, 12:19 p.m.

the input number is never printed

• commented on Jan. 28, 2020, 9:02 a.m.

I'm not printing the input number. 75 is the number of letters for the input. I still don't understand what's wrong.

• commented on Jan. 28, 2020, 10:35 p.m. edit 2

Your code outputs onebilliontwohundredthirtymillionfivehundredsixtyseventhousandandeighthundredninety when the input is 1234567890. In addition, you don't print and after the thousands place. onethousandeighthundred not onethousandandeighthundred.

• commented on April 6, 2019, 11:06 p.m. edited

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on April 7, 2019, 10:45 a.m.

The problem can use any combination of the numbers above, for example 113, which is hundredthirteen

• commented on Jan. 24, 2019, 9:37 p.m.

What does it mean when it says "Do not prompt for input"?

• commented on Jan. 25, 2019, 12:43 p.m.

that means don't print anything like (for example): enter a number or something of that sort, only print the output that is specified in the problem statement

• commented on Nov. 15, 2018, 8:10 a.m.

In the question, how would you name the number 1947471476?

• commented on Nov. 30, 2018, 6:58 p.m. edited

1,947,471,476

onebillionninehundredfortysevenmillionfourhundredseventyonethousandfourhundredseventysix

• commented on Nov. 15, 2018, 12:33 p.m. edit 2

Probably just put in each unit like the others, separating by million/thousand (word form)

• commented on Oct. 4, 2018, 7:15 p.m.

ok, so how do you make 7 into seven?

• commented on Oct. 4, 2018, 8:18 p.m.

Hint: Think about storing the words into an array (or vector or Arraylist)

• commented on Oct. 3, 2018, 5:48 p.m.

Hey, I just spent a lot of time on my Python code (that I hope works properly). However, when I went to submit it, I found out that the library that I used can't be imported. I was wondering if there is a way to fix that (or at least if there is a way to know what libraries can't be used for the future). Thanks!

• commented on Oct. 4, 2018, 12:52 a.m. edited

Only packages included in a standard CPython installation are available. That excludes pretty much everything on PyPI.

• commented on Oct. 9, 2018, 9:23 p.m.

Okay, thanks a lot!

• commented on Oct. 1, 2018, 5:50 p.m. edited

Explanation for Sample Output 2

onehundredone = 13 letters, thirteen = 8 letters

• commented on Oct. 1, 2018, 6:17 p.m.

Fixed it.