47
6
Winner: professorfish's bash answer! An entire 9 bytes! Wow!
You may continue to submit your answer, however you can no longer win. Original post kept for posterity:
Your goal is to convert a whole number between 1-9 into the word it represents.
- You will not need to worry about decimals
- The user will input a number. Assume that they will never enter anything 10 or higher
- The user must type the number at some point, however the method the program reads it does not matter. It can be with stdin, reading a text file, etc, however the user must press the 9 button on their keyboard (for example) at some point
- It is not case sensitive (ie, "one", "One", "oNe", "OnE", etc are all acceptable)
- HTTP/etc requests are allowed, however any code executed by the server the request is made to counts towards the byte count of your final code (e.g. if I had a C++ program make a HTTP request, the PHP code used in the HTTP request counts)
- Anything that can compile and run is acceptable
- This contest has ended on June 27th, 2014 (7 days from posting).
- This is a code-golf, so the shortest code wins
The "winning" answer violates a standard loophole - no relying on external sources.
bsdgames
is not included with bash most of the time. – noɥʇʎԀʎzɐɹƆ – 2016-07-20T18:35:23.7332Is trailing whitespace (i.e.
one
) acceptable? – grc – 2014-06-21T05:13:57.7531@grc Yes, as long as the program outputs the word. – Jon – 2014-06-21T05:14:21.180
The user must type the number at some point. It can be with stdin, reading a text file, etc, however the user must press the
9
button on their keyboard (for example) at some point. – Jon – 2014-06-21T05:18:52.907In languages like Julia, you can input variables at the prompt like this:
n=5
- can we use this as our input method, and count then=
part as 2 characters in our code, and then usen
in the rest of the code? – Glen O – 2014-06-21T06:43:13.790You can do whatever you want as long as the user inputs the character
5
at some point (have them enter it, append it yourself, etc) – Jon – 2014-06-21T06:45:41.4201you should specify that only the given number may be printed and not the other numbers. – Pinna_be – 2014-06-21T07:04:44.170
1@Pinna_be for example, if I input
3
, you can't outputone two three four five six seven eight nine
even though you technically outputthree
. Similarly, you can't outputthree seven
, etc. – Jon – 2014-06-21T07:06:59.010So we can use multiple files and the final byte count is just the sum of the files' byte counts? – Dennis – 2014-06-21T15:27:41.570
Do spoken words count? – CousinCocaine – 2014-06-23T11:14:55.510
Can the output be as a file? – Οurous – 2014-06-23T11:25:54.210
1This question was quite nice. But I don't like the adding of the date limit. Especially, the date limit has been added just before the date limit, not 7 days before. – Nicolas Barbulesco – 2014-06-26T18:12:54.620
1
If http://codegolf.stackexchange.com/questions/32151/convert-1-2-3-4-5-6-7-8-and-9-to-one-two-three-etc/32493#32493 answer is accepted, why isn't mine which is exactly the same, only shorter? http://codegolf.stackexchange.com/a/32298/15168
– CousinCocaine – 2014-06-27T12:41:01.613Because you edited your answer to make it valid after the deadline. As of the deadline you had an invalid submission. – Jon – 2014-06-27T18:18:29.230
@CousinCocaine — Spoken words are words. ;-) In fact, spoken words existed long before written words. – Nicolas Barbulesco – 2014-06-28T18:07:27.497
Chipperyman, Except that the answer you declared winner ex æquo is invalid too, for the same reason as you rejected the answer by @CousinCocaine. – Nicolas Barbulesco – 2014-06-28T18:11:44.253
I never said spoken words aren't words, however as of the contest ending, it only worked if the input was 4. And Nicolas, can you link me to the rejected answer? I might have just not noticed it if it is <= 9 chars. – Jon – 2014-06-28T18:15:06.527
Chipperyman has declared the answer by Registered User winner ex æquo. But this answer misses taking the input. The other solutions — including mines — would be shorter too if they placed the “input” directly at the target spot. Besides, Chipperyman has rejected the answer by CousinCocaine because it missed taking the input. In addition, the answer by Registered User is a replica of CousinCocaine's answer. This is unfair — to say the least.
– Nicolas Barbulesco – 2014-06-28T18:21:48.8731Oh, he told me that it worked for any number and I didn't know the language so I figured I was missing something. I guess he didn't win. – Jon – 2014-06-28T18:22:57.423
What is labelled “original post” here is not the original post.
– Nicolas Barbulesco – 2014-06-28T18:32:32.660I feel like you're just trying to argue with me at this point. I (in my opinion) obviously meant the post before the winner was announced. Does it really matter that it's not the true original post? – Jon – 2014-06-28T18:40:04.347
"Original post kept for prosperity": I think you meant posterity (future generations), not prosperity (getting rich). – NinjaBearMonkey – 2014-07-27T15:12:34.657