# 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 , so the shortest code wins
• Is trailing whitespace (i.e. one ) acceptable? – grc Jun 21 '14 at 5:13
• @grc Yes, as long as the program outputs the word. – Jon Jun 21 '14 at 5:14
• you should specify that only the given number may be printed and not the other numbers. – Pinna_be Jun 21 '14 at 7:04
• @Pinna_be for example, if I input 3, you can't output one two three four five six seven eight nine even though you technically output three. Similarly, you can't output three seven, etc. – Jon Jun 21 '14 at 7:06
• This 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 Jun 26 '14 at 18:12

<?=[0,one,two,three,four,five,six,seven,eight,nine][$argv[1]];  If you read from standard input it goes up to 66 characters. <?=[0,one,two,three,four,five,six,seven,eight,nine][fgetc(STDIN)];  # Bash, 64 d=(z one two three four five six seven eight nine) echo${d[\$1]}


Takes the first argument as a number and uses it as an array index to print the corresponding word.

# Python

here is a simple answer. In python, if you have a key-val mapping pair, you use a dict. this program waits for an input, (0-9) and converts it

n={
1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',0:'zero'}
print n.get(int(raw_input()))


# Python 34 / 28

For this code to work, you have to install num2words module. Also thanks to @undergroundmonorail for his suggestion.

import num2words
num2words(input())


If input() is not necessary , and user is allowed to enter number directly into code, then

import num2words
num2words(3)


will also work.

• Why not num2words(raw_input())? Or even input(), since it's guaranteed to be a number? – undergroundmonorail Jun 25 '14 at 8:32
• @undergroundmonorail Thanks. didn't knew about it. I'm not too good in python. – Registered User Jun 26 '14 at 4:23

In AppleScript ; 53 chars.

say(display dialog""default answer"")'s text returned


Here is a nicer version :

set n to text returned of (display dialog "?" default answer "")
say n


This script takes the input in a dialog. Then it tells the output to the user. The user does not even have to read ! This solution works even for people who are unable to read.

## swipl: 104 bytes

get_char(C),number_codes(X,[C]),nth0(X,[o,one,two,three,four,five,six,seven,eight,nine,ten],Y),write(Y).


## Brainfuck: 672 bytes

+>,-------------------------------------------------[-[-[-[-[-[-[-[[-]+
[------->++<]>.-----.+++++.---------.[-]<[-]>[-]]<[[-]--[----->+<]>-.++
++.--.+.++++++++++++.[-]<[-]>[-]][-]<[-]>[-]]<[[-]+[--------->++<]>+.++
++[->+++<]>.[--->+<]>-.+[->+++<]>.+++++++++.[-]<[-]>[-]][-]<[-]>[-]]<[[
-]+[--------->++<]>+.----------.-[--->+<]>.[-]<[-]>[-]][-]<[-]>[-]]<[[-
]--[----->+<]>.+++.[->++++++<]>.+[->+++<]>.[-]<[-]>[-]][-]<[-]>[-]]<[[-
]--[----->+<]>.+++++++++.++++++.---.[-]<[-]>[-]][-]<[-]>[-]]<[[-]------
--[-->+++<]>.------------.++++++++++.-------------..[-]<[-]>[-]][-]<[-]
>[-]]<[[-]--------[-->+++<]>.+++.--------.[-]<[-]>[-]][-]<[-]>[-]]<[[-]
+[------->++<]>+.-.---------.[-]]

• IMHO and according to the rules the content of "swipl" should be counted, too. Technically it's a request to another program or am I wrong? – german_guy Jun 23 '14 at 12:40
• Ups!. I'll change it. Thanks @german_guy – rpax Jun 23 '14 at 13:21
• @german_guy changed! – rpax Jun 23 '14 at 13:29
• @ProgramFOX I'm sorry I don't understand you. Now it is using only swipl. – rpax Jun 23 '14 at 13:55
• @rpax Ah, now I see. I thought you were only using bash now. I'm sorry. – ProgramFOX Jun 23 '14 at 14:12

# Sprects, 61 bytes

#<INPUT>#9nine#8eight#7seven#6six#5five#4four#3three#2two#1one#0zero


Replace <INPUT> with the number, because Sprects does not have any other form of input (bytecount is without the "input".)

# ///, 80 79 bytes

/_/\/\///0/zero_1/one_2/two_3/three_4/four_5/five_6/six_7/seven_8/eight_9/nine/


Append the number at the end of the code (this is ///'s input).

• Nine // is just enough for /_/\/\// to save a byte. – Martin Ender Jul 21 '16 at 9:37
• @MartinEnder As I told you in another comment, this won't work, because then _ will evaluate to \/\/, not //. If you want to prove it works, please comment a link to an example using this. – Erik the Outgolfer Jul 21 '16 at 9:39
• slashes.tryitonline.net/… – Martin Ender Jul 21 '16 at 9:42
• @MartinEnder So that is the reason I've had problems with forward slashes (/) in the past... – Erik the Outgolfer Jul 21 '16 at 9:44

# C, 92 89 bytes Japanese(Hiragana , Katakana)

Hiragana (ひらがな)

h(n){char*h="いちに　さんし　ご　ろくななはちきゅ";printf("%.6s%s",h+--n*6,n^9?"":"う");}


Katakana (カタカナ)

k(n){char*k="イチニ　サンシ　ゴ　ロクシチハチキュ";printf("%.6s%s",k+--n*6,n^9?"":"ウ");}


http://sp.cis.iwate-u.ac.jp/sp/lesson/j/doc/numbers.html

ideone it!

• Does this actually output in japanese? – Erik the Outgolfer Jul 20 '16 at 21:55
• Yes. ideone.com test. @Eʀɪᴋ ᴛʜᴇ Gᴏʟғᴇʀ – o79y Jul 21 '16 at 3:34

# Factor, 11 bytes

a builtin: number>text.

## protected by Doorknob♦Jun 23 '14 at 19:41

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).