# 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, 2014 at 5:13
• @grc Yes, as long as the program outputs the word.
– Jon
Jun 21, 2014 at 5:14
• you should specify that only the given number may be printed and not the other numbers. Jun 21, 2014 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, 2014 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. Jun 26, 2014 at 18:12

$><<%w[a one two three four five six seven eight nine][gets.to_i]  # Zozotez Lisp: 122 78 ((\(1 2 3 4 5 6 7 8 9)(p(e(r))))'one'two'three'four'five'six'seven'eight'nine)  Zozotez is a LISP-1 interpreter written in Extended BrainFuck. It's only data types are symbols and cons and supports first class functions and macros # Extended BrainFuck: 130 {z(-))}{b&z)<(-}+>,49-(-(-(-(-(-(-(-((-)<-|<nine<&z<(-|<eight<&b |<seven<&b|<six<&b|<five<&z)<(-|<four<&b|<three<&b|<two<&b|<one<&z  EBF is a superset of BrainFuck but it has not it's own runtime. It compiles to pure BrainFuck. Forth (gforth) 36 base ! nine eight seven six five four three two one 0  Usage: 1 pick . ONE ok 2 pick . TWO ok 3 pick . THREE ok 4 pick . FOUR ok 5 pick . FIVE ok 6 pick . SIX ok 7 pick . SEVEN ok 8 pick . EIGHT ok 9 pick . NINE ok  where ok is printed by the interpreter. In fact, I do not know how to count characters in this. One might even say that this is not a program. ## Haskell : 89 do x<-readLn;print$[[],"one","two","three","four","five","six","seven","eight","nine"]!!x


<?=[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? Jun 25, 2014 at 8:32
• @undergroundmonorail Thanks. didn't knew about it. I'm not too good in python. Jun 26, 2014 at 4:23

## 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? Jun 23, 2014 at 12:40
• Ups!. I'll change it. Thanks @german_guy
– rpax
Jun 23, 2014 at 13:21
• @german_guy changed!
– rpax
Jun 23, 2014 at 13:29
• @ProgramFOX I'm sorry I don't understand you. Now it is using only swipl.
– rpax
Jun 23, 2014 at 13:55
• @rpax Ah, now I see. I thought you were only using bash now. I'm sorry. Jun 23, 2014 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. Jul 21, 2016 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. Jul 21, 2016 at 9:39
• slashes.tryitonline.net/… Jul 21, 2016 at 9:42
• @MartinEnder So that is the reason I've had problems with forward slashes (/) in the past... Jul 21, 2016 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? Jul 20, 2016 at 21:55
• Yes. ideone.com test. @Eʀɪᴋ ᴛʜᴇ Gᴏʟғᴇʀ
– user56344
Jul 21, 2016 at 3:34