36
4
CodeGolf Challenge
PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe detects that you are from the year 2000. Because of this, and a few stereotypes, you are assumed stupid compared to today's modern human and are forced to repeat gradeschool.
You enter your first grade classroom and the teacher is giving an assignment. She will say or write a number up to 50. If she writes the number on the board (for example: 25) then you have to say the numbers up to that number "one, two, three, ..., twenty-five". If she says the number out loud (for example: "six") then, on your tablet, you have to write the numbers up to that number "1, 2, 3, 4, 5, 6"
This becomes very tedious and you decide you will automate the process with your still functioning, yet archaic, 21st century programming knowledge.
Objective:
Your program should take an input. This input will either be a decimal number (1 thru 50
) or a written-out number (one thru fifty
).
•If the input is a decimal number, your output should count from one to said number, using written-out style. (e.g. thirty-two)
•If the input is a written-out number, your output should count from 1 to said number, using decimal style. (e.g. 32)
Rules:
Input and Output can be in any case of your choosing (so you can make a program that only accepts upper-case if desired).
Input decimal numbers do not have to be of a number type (e.g. int), they can be a input string containing numbers (25 vs "25"). Either are fine and you can chose which one you want your program to accept. (Your program does not need to accept both)
Written out style does NOT require a hyphen between compound words, but you can if desired.
Output values have to be separated in some form, any separator is fine 1,2,3
1 2 3
etc
You can not add extra libraries like num2words (python) etc (However system libraries are fine)
Even though the back-story says you are from the year 2000, you can use languages created after that date (lol)
This is code-golf, so the program with the shortest bytecount wins!
1
Are we allowed to use libraries like num2words in case of python.
– Gurupad Mamadapur – 2017-01-31T09:56:06.687@GurupadMamadapur thank you for asking, I am going to say no for the sake of this challenge, I think it takes too much fun out of it. Editing this into my post – Albert Renshaw – 2017-01-31T09:58:57.560
Just to be clear: "either" doesn't mean we have to choose the format we prefer, right? an answer should be able to handle both kinds of inputs (numbers and words). – coredump – 2017-01-31T13:24:27.027
Related: http://codegolf.stackexchange.com/q/57053/21348
– edc65 – 2017-01-31T13:27:43.2071@AlbertRenshaw but what about builtins that do that? (Mathematica) – Pavel – 2017-01-31T18:06:56.293
1@coredump Either means you can pick one or the other or both. It doesn't have to be able to handle both kinds of inputs – Albert Renshaw – 2017-01-31T19:43:14.610
@AdmBorkBork system libraries are fine, edited into post. – Albert Renshaw – 2017-01-31T19:47:55.080
@Pavel those languages have an advantage I suppose, answers might be kind of boring though, I'm really enjoying seeing the creative solutions in languages that don't support that. This answer is great imo: http://codegolf.stackexchange.com/a/108776/16513
– Albert Renshaw – 2017-01-31T19:48:35.793@AlbertRenshaw Ok thanks – coredump – 2017-01-31T20:44:45.950
2"Bite my shiny metal ass!" I won't count myself – RaisingAgent – 2017-02-01T13:22:17.750
1I keep thinking the title is "your first (grade counting)" not "your (first grade) counting" – CAD97 – 2017-02-03T14:36:56.440