text:
Convert 1, 2, 3, 4, 5, 6, 7, 8, and 9 to "one", "two", "three", etc
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

Is trailing whitespace (i.e. one  ) acceptable?

@grc Yes, as long as the program outputs the word.

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.

In languages like Julia, you can input variables at the prompt like this: n=5 - can we use this as our input method, and count the n= part as 2 characters in our code, and then use n in the rest of the code?

You 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)

you should specify that only the given number may be printed and not the other numbers.

@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.

So we can use multiple files and the final byte count is just the sum of the files' byte counts?

Do spoken words count?

Can the output be as a file?

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.

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

Because you edited your answer to make it valid after the deadline. As of the deadline you had an invalid submission.

@CousinCocaine — Spoken words are words. ;-) In fact, spoken words existed long before written words.

Chipperyman, Except that the answer you declared winner ex æquo is invalid too, for the same reason as you rejected the answer by @CousinCocaine.

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.

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.

Oh, 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.

What is labelled “original post” here is not the original post.

I 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?

"Original post kept for prosperity": I think you meant posterity (future generations), not prosperity (getting rich).

The "winning" answer violates a standard loophole - no relying on external sources. bsdgames is not included with bash most of the time.

I wonder which human language has number names that are most compressible.

Bash (with bsdgames), 9
number -l

Reads from standard input.
I don't know why there's a utility for this, but whatever.

I'm not sure I like installing bsdgames and then calling it "bash", though I'll admit that my reservation is subjective.

@PaulDraper Neither do I. I didn't post this as a serious answer, I think one of the other answers deserved to be accepted

Ain't this a standard loophole?

@Quincunx yes, it basically is. Although most things are external utilities in Bash, I wouldn't count the bsdgames package as something very permissible (unlike grep, wget, coreutils, sed, bc...).

Python 2, 64
print' ottffssennwhoiieiieoruvxvgn  ere ehe  e   nt'[input()::9]

This is what the string looks like with some extra whitespace (try reading vertically):
o t t f f s s e n
n w h o i i e i i
e o r u v x v g n
    e r e   e h e
    e       n t

As explained in the comments below, [input()::9] starts at the given index and selects every ninth subsequent character.

Oh, shit, I like this. Probably worth pointing out that this is python 2, by the way.

Explain please! :)

@ChristoferOlsson input()::9 is a range from input() to the end of the string in steps of 9, like 1,10,19,28,37 or 3,12,21,30,39, which are exactly the indices at which the letters for the corresponding word are found.

@m.buettner thanks! That's nice.

Python 3 would only be 7 characters longer right? The brackets for print() and adding int() around the input(). Also would be safer than using Python 2's input.

@JeromeJ yes, that's correct.

Isn't this something like what a rail-fence cipher does? (+1 for a neat solution by the way.)

Visual, clever. I like this one !

Common Lisp - 22 bytes
Here's a general one (not just for one-ten):
(format nil"~R"(read))

Oh, you want ordinals (first, second, ... three-hundredth...)? Ok!
(format nil"~:R"(read))

Isn't this a standard loophole?

Loophole in what sense? It's clearly defined in Hyperspec: http://www.lispworks.com/documentation/lw50/CLHS/Body/22_cba.htm

As in this: http://meta.codegolf.stackexchange.com/a/1078/20356

Whether it's a standard loophole or not, it's what I came here to post, too.  +1 :)

@TheRare I'll remember for the next time. Although I don't quite agree with it.

@TheRare Looking at the comments to that answer, I don't think there is strong community consensus that this is a loophole.  My feeling is that questions need to explicitly ban use of this kind of built in function if they are not to be used.

@DigitalTrauma That is the reason I asked if it's one. Might be that my meaning got a little warped.

This seems more like an answer in SO than in PCG to me...

BASH 51
So I made another one using my second idea plus some help from others:
set one two three four five six seven eight nine

$X

Where 'X' is the number you want.

BASH 48 (67)
67 with \n line breaks
I'm not sure if this totally counts, because it's reading from a file, but:
sed -n Xp a
Where "X" is the input and where a is a file with:
one
two
three
four
five
six
seven
eight
nine

The file is 36 chars, and the bash command is 13.
How it works:

 Each line in the file is numbered, starting with 1. So 'one' is on the 1st line, 'two' on the 2nd. The command, sed -n 'Xp' a says, "Please print what's listed on line 'X' of file 'a'" sed is a Unix stream editor. -n means be silent, or only essentially ignore everything else. Xp means print what's on line 'X'.

@Quincunx updated my post from 46 -> 49

@Quincunx I added a spoiler. Hopefully I explained it well.

Nice first answer! Thank you for taking the time to figure out how we format our answers on this site. Welcome to Programming Puzzles and Code Golf!

For the record, this does fit within the rules because you could reasonably assume the text file had a number input by the user.

You didn't count the linefeeds in a.

One byte less than before, accepts a command-line argument and doesn't require additional files: http://pastebin.com/qdbXKQGP Bash will complain about the missing heredoc delimiter, but it will run fine with Dash and Zsh.

@Dennis oh cool I like it. Am I supposed to edit my answer with yours now? Sorry, am new to code golf.

That depends entirely on you.

You can omit the ' quotes.  You could also try using a here string instead of the external file.  But you really should count the line breaks in your file.

You might be able to use the d command within sed instead of -n

@Dennis I'll add yours in when I get back to my laptop. I'm on my phone at the moment and it's hard to edit.

It certainly is. By the way, your new approach is very similar to professorfish's. Yours has a syntax error; Bash uses () for array declaration, not [].

@Dennis you're right. I fixed it. Stupid error because I wrote too much JS.

You're also missing the echo.

@Dennis technically it prints the correct number, plus a bunch of other junk. If you only wanted the number you'd use echo, yes.

So that was by design. Sneaky! It's customary to count functional whitespace, so one linefeed between the first and the second command has to be counted. That gives a total of 58 bytes. I'd also change X to $1 to comply with the question's input requirements.

I'm not sure I under stand the "change x" part @Dennis

I won't pretend that I fully understand the input requirements of this question, but the usual forms of accepting user input with Bash scripts/functions are reading from STDIN and command line arguments. $1 refers to the first argument or the script/function, so it's the cheaper choice.

set one two ... nine then user input is ${!X}  to save 4 bytes

@Dennis Oh, okay. I see what you mean. I updated it using set and $X

Oh, and I should mention thanks for the warm welcome, @Quincunx Also, are line breaks 1 or two bytes?

They count as one byte.

59 bytes: sed -n $1p<<<'one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine' (replace \ns with line breaks). Takes a number as command line argument.

The first solution, with $1, misses the input.

What shell are you using @Nicolas Barbulesco ?

@eric_lagergren — I tested this with bash on Mac OS X. This does not work. I did test your code, $X. The answer has to take the digit as input. I don't have to edit the script to place the digit inside the code.

@NicolasBarbulesco the question doesn't ask for the input to be inside the code. It just says 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

C# - 127 ( 86 / 46)
If you only take the executable part...
Console.Write(((HourOfDay)Console.Read()-48));

and if HourOfDay would have been part of the the System namespace you would need 46 chars. Unfortunately it sits in System.DirectoryServices.ActiveDirectory which makes it 86...the other noise spoils it.
This is compileable and runnable from the commandline (127 chars):
using System;class P{static void Main(){Console.Write((System.DirectoryServices.ActiveDirectory.HourOfDay)Console.Read()-48);}}

if saved to a file called cg2.cs
csc cg2.cs /r:System.DirectoryServices.dll  && cg2

How does this work?
HourOfDay  is an enum type so we can use names instead of magic constants. Enum types have a ToString() implementation that gives you the name of the value. You can cast an int to an enum. Console.Read() reads a character from the input stream represented as an integer. typing '1' gives 49, substract 48 to get 1, cast/box to HourOfDay to return 'One'.
Take a look at the Powershell version of this same trick

How does this work ? Let's say I enter 9. What does the program do then ?

I love how Micro$oft presents things ! The order of the entries is completely absurd. ^^

What does this -48 do here ?

@NicolasBarbulesco added an How does this work? paragraph. Does it make sense?

Rene, thank you, it is clearer now. The -48 is there to convert character code to integer.

@NicolasBarbulesco - It's sorted alphabetically.  Which makes sense in every context except "These words are numbers".  Since I'm sure the documentation is automatically generated, it wouldn't make sense to special case the one article.

In reality, the cast to HourOfDay occurs before the subtraction (cast operator has higher precedence than -), but to my surprise C# still allows that.

@Timwi Hmmm, The IL doesn't show a cast OpCode but only a box OpCode just before the call to write to get an object?!

@Bobson — The alphabetical order is non-sense. The days in the week are friday, monday, saturday, sunday, thursday, tuesday, wednesday. :-)

@NicolasBarbulesco - Yep.  Do note, though, that the order they are listed in is not the order of their int values.  "The value of the constants in this enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday)."

Befunge 98, 116 105 103 bytes
&1-       v
vvvvvvvvvj<
"""""""""
etnxereoe
nheivuewn
igvsiorto
nie"ffh""
"es ""t
 ""   "
>>>>>>>>>4k,@

Befunge was not made for this...
Explanation:
&1-           ;Grab the input number (`n`) and subtract 1 from it
&1-       v   ;Start moving downwards
          <   ;Start moving leftwards
         j    ;Jump `n - 1` characters to the left.
vvvvvvvvvj    ;Redirect each of the possible locations to jump to, sending the IP down.

        "     ;If `n` was 1, push `o, n, e` onto the stack (`o` is at the bottom)
        e
        n
        o
        "

       "      ;If `n` was 2, push `t, w, o` onto the stack
       o
       w
       t
       "

    *
    *
    *

"             ;If `n` was 9, push `n, i, n, e` onto the stack
e
n
i
n
"

>>>>>>>>>     ;Collect all the different possible positions the IP could be in, and send it right
>>>>>>>>>4k,  ;Print the top 5 chars. If there are less than 5, the rest are null characters. This is allowed
            @ ;End of program

@Dennis I can't see how that could be so hard. Simply take the file, turn it into a char[][], keep an x and y location, and execute the character at that location. The hardest thing would be defining the operation for every possible character.

You can easily save two bytes with a &1-.

Javascript 68
Atob / btoa can be a poor's man compressing tool
 (but if you want to try this in console, you cannot copy from the formatted text you see at once. Go to 'edit' and copy from the source panel)
Markdown editor does not like some of the characters in this answer: some characters get lost at saving. Still, I think it's an editor problem, not mine. The lost characters are perfectly valid 8 bit unicode chars.
(Or else I'm wrong, if this issue was already debated in meta, let me know)
Here is the version with offending characters escaped, each sequence \xNN should count 1
alert(btoa("×C§{Dð£Dáç´\x16\x8b«ÐX¯{D¢ÇD\x9e½éô\x12(!·Cb\x9dí").split(0)[prompt()])

Simple Test
In firefox console:
[0,1,2,3,4,5,6,7,8,9]
.map(x=>x +',' btoa("×C§{Dð£Dáç´\x16\x8b«ÐX¯{D¢ÇD\x9e½éô\x12(!·Cb\x9dí").split(0)[x])

I tried something similar but couldn't figure out a valid base64 string starting with a number. I think you answer has been corrupted by stackexchange though.

@nderscore, damn your'right. Amending the post, still it's valid according to me

With the version that has the escaped characters, everything works but 3 and 8, the output Tree and EightF.

@Quincunx 'Tree' is me not speak english

Javascript 73
alert('0one0two0three0four0five0six0seven0eight0nine'.split(0)[prompt()])

69
alert(btoa("ôéÞõ5õ1ëxO_¢êý|ÞöÈ±õ'xß^hSôØ§{Ý").split(9)[prompt()])

Technically wouldn't alert('0one0two0three0four0five0six0seven0eight0nine'.split(0)[#]) be the same thing but save you 8 bytes? The user still inputs the number they want...

@eric_lagergren do you mean the user would have to change the number in the source? I don't think that would count as input.

Oh, okay, I see what you mean. I suppose if you ran it like a command in the console it'd be part of the input as opposed to the source.

Perl, 55
$_=(nine,eight,seven,six,five,four,three,two,one)[-$_]

It is run with option -p (+1 byte), e.g.:
perl -pe '$_=(nine,eight,seven,six,five,four,three,two,one)[-$_]'

Input is expected in STDIN and output is written to STDOUT.
The code just generates an array and selects the right element. Option -p takes care of reading the input line into $_ and prints the result in $_.
Variations:

With trailing new line (+3):
$_=(nine,eight,seven,six,five,four,three,two,one)[-$_].$/

or (same byte count):
s/./(nine,eight,seven,six,five,four,three,two,one)[-$&]/e

Update:

Using bare words instead of qw[...] (thanks Zaid).
Negative index saves a byte (thanks aragaer).

Save a couple of characters: $_=(one,two,three,four,five,six,seven,eight,nine)[$_-1]

@Zaid: Thanks, it saved two bytes. (I am to used to use strict).

I don't like that "-1". $_=(nine,eight,seven,six,five,four,three,two,one)[-$_] - one character shorter.

@aragaer: Thanks, nice idea.

Oracle SQL - 46
select to_char(to_date(&1,'j'),'jsp')from dual

Demonstration
This does include a standard loophole, I admit, but the SQL is shorter than Golfscript; I couldn't resist!
It works by (ab)using Oracle's datetime format models. TO_DATE(n, 'j') converts a number into a Julian day, the number of days since January 1, 4712 BC. TO_CHAR(<date>, 'jsp') converts this back into the integer (though as a string). The sp, is a format element suffix that spells the number. This'll actually work with quite a lot of numbers.
The &1 is a substitution variable that'll only work with clients that accept it, for instance SQL*Plus.

I have a love/hate relationship with Oracle's RDBMS but this is nice.

CJam, 45 43 bytes
"^AM-^L8M-xM-^L^US^_M-^WrM-rM- 1M-s^CHM-|M-X^HE,M-qM-^EM-q4"256bKb'ef+'j/li=

The above uses ^ and M- notation, since some characters are unprintable.
At the cost of 9 more bytes, unprintable characters can be avoided:
" one two three four five six seven eight nine"S/li=

Try it online.
How it works
" Convert the string into an integer by considering it a base-256 number.                ";

"^AM-^L8M-xM-^L^US^_M-^WrM-rM- 1M-s^CHM-|M-X^HE,M-qM-^EM-q4"256b

" Convert the integer from above into an array by considering it a base-20 number.       ";

Kb

" Add the ASCII character code of “e” to all elements of that array. This casts to char. ";

'ef+

" So far, we've pushed the string “jonejtwojthreejfourjfivejsixjsevenjeightjnine”.       ";

" Split the the above string where the character “j” occurs.                             ";

'j/

" Read an integer from STDIN and push the corresponding substring.                       ";

li=

Example
$ base64 -d > convert.cjam <<< IgGMOPiMFVMfl3LyoDHzA0j82AhFLPGF8TQiMjU2YktiJ2VmKydqL2xpPQ==
$ wc -c convert.cjam
43 convert.cjam
LANG=en_US cjam convert.cjam <<< 5
five

Wow, our answers are identical, even in length (I assume the user inputs a string).

@Quincunx: Alike minds think great! :P But reading user input will cost two bytes in CJam, so I'll have to think of something else...

@Quincunx: It should work with GolfScript as well, although it probably won't save bytes. Base64 dump: IgGMOPiMFVMfl3LyoDHzA0j82AhFLPGF8TQiMjU2YmFzZSAyMGJhc2V7MTAxK30lIiIr

This is what I managed to come up with; it's longer: http://golfscript.apphb.com/?c=Oyc5Jwp%2BIgEELDBETApwEBAWBDdoR3tjN3FyVBp6QgQRH10iW3t9L10xMjhiYXNlW3suMjAlMTAxK1wyMC8ufWRvO10nZScrJ2onLz0%3D

Do you know what encoding golfscript expects for non-ascii characters? It seems to not be utf-8

@Quincunx: The official interpreter depends on $LANG. I don't know that the online interpreter does.

Okay. I give up. I managed to write something, but it doesn't work. At least I learned how to do file-io in python, though.

I haven't checked, but I don't think the :c is necessary, since int + char should give char.

bash say (OS X): 3 8
"Your goal is to convert a whole number between 1-9 into the word it represents"
Last time I checked, spoken words are words as well.
Previous attempt (accepts no input)

say 4

Edit, must be able to read input:
say|read

Type any number and the word comes out. I know the end date is due, but in my opinion I should have won the contest.
Example audio file: four.aiff

shouldn't be 5?

@rpax I don't believe the input is counted as a character, is it?

Thinking again...no. +1

This is clever. But this misses the input.

Unfortunately this is not a valid answer because: It never accepts input from the user AND it only works if the number is 4.

CousinCocaine, you should say something how to run this answer : in the Terminal.

The comment by Chipperyman on this answer by CousinCocaine is true. But it is true for the answer by @RegisteredUser too. However, Chipperyman has rejected this answer by CousinCocaine, and has declared the answer by Registered User winner ex æquo. In addition, the answer by Registered User is a replica of this answer by CousinCocaine. This is more than unfair.

GolfScript, 51 bytes
~'
one
two
three
four
five
six
seven
eight
nine'n/=

It's a simple lookup table. The input is evaluated (~), an array of the values is created, and the index is found.
Try it here

The user must input a string, you can't have it hard-coded. Also, your Try it here link has different code than the pasted code.

@Chipperyman The user does input a string in this program. The Try it here link's difference in code is because the webpage does not support user input. Change the string after the ;, this is identical to user input.

Ah, I see. I don't know golfscript very well, thanks for letting me know.

@Chipperyman: GolfScript places the contents of STDIN on the stack before executing the script itself.

Hah! I can beat you by one byte! ;-)

Perl, 60 bytes
$_=(ZOneTwoThreeFourFiveSixSevenEightNine=~/.[a-z]*/g)[$_]

Requires the -p switch (two bytes).
Example
$ perl -p convert.pl <<< 5
Five

How it works

-p reads from STDIN and saves the result in $_.
=~/.[a-z]*/g splits the preceding bareword into substrings of one (uppercase) letter followed by any number of lowercase letters.
(…) collects the substrings into an array.
[$_] retrieves the substring corresponding to the user input.
$_=… saves the result in $_.
-p prints the value of $_.

I like the regex trick. +1

Bash + coreutils, 64
Non-competitive compression concept
xxd -p<<<TàPnàõ:àsÀ~®@ãCN|tr 0-9a-d \\ng-inor-x|sed -n $1p

Some of the exotic characters here may not render well, so this script may be reconstructed from its base64 representation:
base64 -d <<< eHhkIC1wPDw8VOCLUIJu4PWWDzrgc8B+rkDjEoBDTnx0ciAwLTlhLWQgXFxuZy1pbm9yLXh8c2VkIC1uICQxcA==

Example output
$ ./n.sh 1
one
$ ./n.sh 9
nine
$

Explanation
It occurred to me that the string one two three four five six seven eight nine contains only the letters efghinorstuvwx and a space separator - 15 character values in total.  Thus each character can potentially be represented in 4 bits, or 2 characters per 1 byte.  We can use the hex representation of a byte as an easy way to split each byte into two hex digits. We can then transform the hex digits back to the letters we require using tr or similar.  As luck would have it, rstuvwx are consecutive, so may be expressed as r-x to tr.  The encoding is arranged such that e and f are left as-is, and that the words are line-break separated, so we can use sed to ouptut just the line we need.
This decoding process ends up using a fair amount of extra space, so makes this answer non-competitive as a shell-script-style answer, but may be a useful concept in other languages.

Python 2.x - 65 64
Not as good as @grc 's answer, but certainly more legible :-)
'one two three four five six seven eight nine'.split()[input()-1]

One less char, thanks to @flornquake
'nine eight seven six five four three two one'.split()[-input()]

This one is nice too. :-) It works.

You can save one character like this: 'nine eight seven six five four three two one'.split()[-input()]

Thats a Nice one !

DOS Batch - 162 Chars (incl' line breaks)
This answer was inspired by @grc's Python answer, although I did have something similar in mind.
@setlocal enabledelayedexpansion
@set s="ottffssennwhoiieiieoruvxvgn  ere ehe  e   nt
@set /a c=%1
@set z=!s:~%c%,1!
@if _%z%==_ exit /b
@echo %z%
@%0 %c%+9

Usage:
[Filename] [number]
For example, if the code is in a file called speak.bat, and you want to see the number "five", you would run it as:
speak 5
Also, the output is top-to-bottom, not left-to-right! So instead of

five

you will see

f
  i
  v
  e

(pure) Bash, 64
Takes input as its first argument, assuming valid input.

v=(o one two three four five six seven eight nine)
echo ${v[$1]}

Creates an array v, then accesses the element specified on the input. Since arrays are zero-indexed, I had to add a 0th element as a placeholder. Alternatively (thnx @DennisWilliamson for pointing this out):
v=(one two three four five six seven eight nine)
echo ${v[$1-1]}

Same character count: v=(one two three four five six seven eight nine) and echo ${v[$1-1]}

Perl 36 (58 standalone)
use Number::Spell;say spell_number<>

Or, without additional modules:
say qw(one two three four five six seven eight nine)[<>-1]

Your first script does not work, on my Mac. Can't locate Number/Spell.pm in @INC (@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at toto.pl line 1. BEGIN failed--compilation aborted at toto.pl line 1.

Your second script does not work, on my Mac. syntax error at titi.pl line 1, near "say qw(one two three four five six seven eight nine)" Execution of titi.pl aborted due to compilation errors.

C 111
#include <stdio.h>
int main(){printf("%.5s","one  two  threefour five six  seveneightnine"+5*(getchar()-'1'));}

The length here is carefully engineered so I can interpret it as binary and convert that to decimal. At only 7 characters, I'm confident I have a winner!

+1  Code-golfers generally don't mind if your c code compiles with warnings, as long as it meets the specs.  So you can omit the #include and main()'s return type.  Also a bit of refactoring of your expression: main(){printf("%.5s","one  two  threefour five six  seveneightnine"+5*getchar()-245);}.  86 chars by my count.

I don't get the length stuff, and I don't see where there would be 7 chars.

@NicolasBarbulesco: It's 111 characters--but if we treat the 111 as binary, that would convert to 7 in decimal.

Jerry, there is code golf running in your head !

Java 7 - 185
class Num{
public static void main(String[] args) {
    System.out.print("ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE".split(",")[(new java.util.Scanner(System.in)).nextInt()-1]);
    }}

Powershell - 91 74
[Enum]::ToObject([System.DirectoryServices.ActiveDirectory.HourOfDay],[Console]::Read()-48)

Found out how to cast to remove the Enum and ToObject call:
[System.DirectoryServices.ActiveDirectory.HourOfDay]([Console]::Read()-48)

How does this work?
HourOfDay is an enum type so we can use names instead of magic constants. Enum types have a ToString() implementation that gives you the name of the constant value. You can cast an int to an enum. Console.Read() reads a character from the input stream represented as an integer. typing '1' gives 49, substract 48 to get 1, cast to HourOfDay to return 'One'.
Because powershell does a ToString on all objects being written to the output stream and doesn't need the fluff to turn this into an executable this all that is needed besides powershell...

In AppleScript ; 123 chars.
{"one","two","three","four","five","six","seven","eight","nine"}'s item((display dialog""default answer"")'s text returned)

This script takes the input in a dialog. Then it gives the output in AppleScript’s result.
Example :

Input : 6
Output : "six"

Here is a nicer version :
set l to {"one","two","three","four","five","six","seven","eight","nine"}
set n to text returned of (display dialog "?" default answer "")
display dialog (l's item n) buttons ("OK") default button 1

This version displays the output in a nice dialog.
Example :

Input : 9
Output : nine

[ Answer edited ; slightly improved the dialog for the input ; still 124 chars. Answer edited again ; now 1 char less ! ]

set n to text returned of ... Wow.

CJam - 50
This is a plain ASCII solution that uses HTTP requests (this is allowed in the question):
"aj21.com/"r+g

On the server there are 9 plain-text files named 1, 2, ..., 9, each containing the corresponding word.
Total size: 14 + 3 ("one") + 3 ("two") + 5 + 4 + 4 + 3 + 5 + 5 + 4 = 50.
It can be golfed more by using a shorter domain.
The online interpreter doesn't support HTTP requests, so the program needs to be run using the java interpreter.

BASH 9
shameless Linux-replica of cousincoicane's answer
spd-say 1

speaks out one

Wouldn't this only work if the input was 1?

@Chipperyman it works for any number

Limit, but clever !

This misses the input.

@nicolasbarbulesco yes. but there were many other answers that miss input, so I went ahead with this.

@Chipperyman — You have accepted this answer, missing the input, but you have rejected the answer by CousinCocaine because it misses the input. And this answer is a replica of CousinCocaine's answer. This is more than unfair.

@RegisteredUser — No, it does not work for numbers ≠ 1.

The other solutions — including mines — would be shorter too if they placed the “input” directly at the target spot.

@NicolasBarbulesco It works for every number.have you checked it on a linux system?

GolfScript, 50 bytes
I wanted to see if I could beat Quincunx's 51-byte self-contained GolfScript solution.  Turns out that, with enough tricks, yes, I can — by one byte.
Since one of the tricks I'm using is the use of bytes outside the printable ASCII range, the resulting program is cannot be directly pasted here.  Instead, I'm providing a hex dump of it; users on Unixish systems can use xxd -r to reconstruct the actual 50-byte GolfScript program from the hex dump:
0000000: 7e6e 270b 97eb 442f e166 9894 9f00 c63c  ~n'...D/.f.....<
0000010: 8128 73a3 9b55 5065 a9fb f06a 2727 ff16  .(s..UPe...j''..
0000020: 277b 6261 7365 7d2f 2b6e 2f3d 7b39 392b  '{base}/+n/={99+
0000030: 7d25                                     }%

The basic trick used to generate this program is simple: I compress the long string literal that makes up most of Quincunx's code by subtracting 99 (the ASCII code of the letter c) from the character values, interpreting the resulting values as a number in base 22 (enough to encode the letters up to x) and then re-encode the resulting number in base 255 to produce the unprintable byte string that makes up most of the first half of my program.  The rest of the program then reverses this process, decoding the string back into something printable.
(Since the lowest letter actually present in the number names is e, I could've shortened the byte string further by subtracting 101 from the ASCII codes and using base 20.  However, subtracting 101 would've mapped the letter o to a newline, which I'm using as the number delimiter because it's conveniently available as the built-in constant n in GolfScript.  Working around that would cost me more than the one byte that using a lower base would save.  Using the offset 99 leaves the newline corresponding to the letter m, which is conveniently absent from the number names.)
Here's a de-golfed version of the program:
~       # eval the input, turning it into a number
n       # push a newline onto the stack; we'll need it later

# this is the byte string encoding the number names:
"\x0B\x97\xEBD/\xE1f\x98\x94\x9F\x00\xC6<\x81(s\xA3\x9BUPe\xA9\xFB\xF0j"

# convert the encoded string from base 255 to base 22
# (and, incidentally, from a string to an array):
"\xFF\x16" {base}/

+       # prepend the newline pushed earlier to the array, re-stringifying it
n/      # split the resulting string at newlines
=       # pick the substring corresponding to the input number
{99+}%  # add 99 to the character values in the chosen substring

Batch - 86
Far shorter than the other batch answer, and actually surprisingly competitive.
for /f "tokens=%1" %%1 in ("one two three four five six seven eight nine") do echo>%%1

Used as filename.bat number, and the output is in the form of a file with the name of the correct number.

VBScript 98 80 75
msgbox split(" one two three four five six seven eight nine")(inputbox(""))

PHP, 93 73 68 bytes
<?=explode(' ','one two three four five six seven eight nine')[1-1];

Try it Online!

This is short-circuiting the input method. The other solutions — including mine, to come — would be shorter too if they placed the “input” directly at the target spot.

Ruby 64
p %w?one two three four five six seven eight nine?[$*[0].to_i-1]

You can chop few more bytes by substituting 9 directly at the place of x

I don't see where this code takes in input.  And why write 9-1 when you can just say 8?  Of course both 9-1 and 8 are wrong; this script outputs "nine" all the time and ignores input.

J - 68 or 60 57 or 53 bytes
Interactive version (stdin):
>one`two`three`four`five`six`seven`eight`nine{~<:".1!:1]1

Function version:
f=:one`two`three`four`five`six`seven`eight`nine>@{~<:

Explanation:
f=:one`two`three`four`five`six`seven`eight`nine>@{~<:
                                                   <: Decrease by one
                                                 {~   Get the correct string
                                               >@     Unbox

".(1!:1)1 reads a string and converts it to integer

You can save one char by writing it as a train ((;:'one two blah')>@{~<:) and another six by using the gerund one`two`blah instead of ;:.

@algorithmshark Thanks! I'm still learning J. Although, wouldn't the train version require the text to be infinite rank (edit: apparently not... why not?) and the gerund version extra quotes (edit: oh, it creates a list of boxes)?

A fork can have a noun in the left argument, which is shorthand for a constant verb producing that noun with infinite rank (q.v. the Dictionary). And no, no extra quotes on the gerund: undefined names are treated as references to verbs, and the gerund for that is just a boxed string containing the name.

Also, you don't have to write the STDIN version as a verb expression: >one`two`three`four`five`six`seven`eight`nine{~<:".1!:1]1 is 3 chars shorter.

@algorithmshark Haha, why didn't I do it that way?

@algorithmshark Also, your website is correct.

Jelly, 35 bytes
ị“¡5ç“¡Ḃḥ“¡Ị¿“Ɱ9“ƁẆ“¡⁹)“¡°Ṗ“z⁷“¡'Ṡ»

Try it online!
Explanation:
 “¡5ç“¡Ḃḥ“¡Ị¿“Ɱ9“ƁẆ“¡⁹)“¡°Ṗ“z⁷“¡'Ṡ» List of numbers 1-9 as words.
ị                                   xth element of y.

APL, 54 bytes
⎕⊃↓9 5⍴'ONE  TWO  THREEFOUR FIVE SIX  SEVENEIGHTNINE '

F# - 101
printf"%s"["one";"two";"three";"four";"five";"six";"seven";"eight";"nine"].[System.Console.Read()-49]

For a newline but 108 bytes, change printf to printfn.
It's a naïve solution that just fetches the given index of that hardcoded list. I would have loved to use base64 encoding and/or a regex to split a string into an array (so the elements would be separated with  instead of ";"), but both of those would just make the solution longer, due to namespaces. Why can't they just be in System like everything else? :'(

You could do Console.Read() like I did in the Csharp version.

@rene ah, didn't know that existed. Thanks! :)

You don't need the parse...http://msdn.microsoft.com/en-us/library/system.console.read(v=vs.110).aspx  you get an int as return value for the ascii code of the char

@rene Didn't see that either... Thanks again! xP

Wait, how does adding a single character make it 124 bytes from 107?

@nyuszika7h oops, I forgot to update that number earlier. Fixed.

Racket / R5RS Scheme: 71 68
(vector-ref'#(z one two three four five six seven eight nine)(read))

It runs in the REPL of R6RS and R7RS with base library loaded too.

You can save 3 characters in the Racket code by using 0 (or any other single character) instead of zero.

@nyuszika7h Thanks. I originally though zero was needed and I forgot to remove it from the Racket version.

@Charles It's done :)

I know I'm not going to win but I just want to participe...
C++11 172
   #include <iostream>
    int main(){ auto a = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };printf("%s", *(a.begin() + getchar() - '0' - 1));}

Javascript - 79 - 69 68: (run on dev console)
["one", "two", "three", "four","five","six","seven","eight","nine"][prompt()-1]
"one,two,three,four,five,six,seven,eight,nine".split(',')[prompt()-1]
",one,two,three,four,five,six,seven,eight,nine".split(',')[prompt()]

C++11 - 133
My answer in C++:
#include<iostream>
main(){char*n[]={"one","two","three","four","five","six","seven","eight","nine"};std::cout<<n[std::cin.get()-'1'];}

The total amount of bytes is 133.

Objective-C - 154 bytes
This one is kind of cheating a little bit because Objective-C has a built in class just for this but I don't see anything in the rules that says I can't do that so here it is!
int i;
scanf("%d",&i);
NSNumberFormatter *f=[[NSNumberFormatter alloc] init];
[f setNumberStyle:5];
NSString *s=[f stringFromNumber:@(i)];
NSLog(@"%@",s);

This is not cheating. This is what I wanted to do in AppleScript, but I did not find the built-in method I wanted. So I wrote the method myself.

Ruby 68
v=%w(one two three four five six seven eight nine);p v[gets.to_i-1]

Would love tips on how to get it down further!

you can eliminate the declaration of v which saves you 4 chars.. that is, p %w(...)[...]

Shell, 42 bytes
cat $1

This relies on files in the current directory, one for each digit.  The lengths of the files are included in the score:
ubuntu@ubuntu:~/n$ ls -l
total 40
-rw-rw-r-- 1 ubuntu ubuntu 3 Jun 22 11:39 1
-rw-rw-r-- 1 ubuntu ubuntu 3 Jun 22 11:40 2
-rw-rw-r-- 1 ubuntu ubuntu 5 Jun 22 11:40 3
-rw-rw-r-- 1 ubuntu ubuntu 4 Jun 22 11:40 4
-rw-rw-r-- 1 ubuntu ubuntu 4 Jun 22 11:41 5
-rw-rw-r-- 1 ubuntu ubuntu 3 Jun 22 11:41 6
-rw-rw-r-- 1 ubuntu ubuntu 5 Jun 22 11:41 7
-rw-rw-r-- 1 ubuntu ubuntu 5 Jun 22 11:41 8
-rw-rw-r-- 1 ubuntu ubuntu 4 Jun 22 11:41 9
-rwxrwxr-x 1 ubuntu ubuntu 6 Jun 22 11:42 n.sh
ubuntu@ubuntu:~/n$

Example Output:
$ ./n.sh 4
four$
$ ./n.sh 7
seven$
$

The names of the files are a key part of the solution. If we count the characters, then the names of the files have to be included. The total length of this solution is 51 (1one2two3three4four5five6six7seven8eight9ninecat $1).

Apple Swift : 143
Not a winner, but my first Code-Golf, so hello everyone!
for i in 1..C_ARGC{print(["zero","one","two","three","four","five","six","seven","eight","nine"][String.fromCString(C_ARGV[Int(i)]).toInt()!])}

What I like about this is that the lookup table is defined in place in print so I could shave a few chars by removing the variable definition for it.
Accepts any number of input arguments, provided that they are separeted with spaces.

Powershell 63
(-split"X one two three four five six seven eight nine")[$args]

(The default delimiter in Powershell is whitespace)

Python 3 + Japanese - 34 characters (52 bytes)
Not sure if this counts:
print('九八七六五四三二一'[-int(input())])

Numbers were taken from:
http://en.wikipedia.org/wiki/Japanese_numerals

Sclipting (34)
껆뭮뉒롴덶묬덆둲뉖넬뉦뭵댢롦늗뉥껇꽩뎂롳뉗뉥닢롥늖덨덂롮늖멥壹坼⓶掘

This is very straight-forward. Remember the user input is first on the stack.
껆뭮뉒롴덶묬덆둲뉖넬뉦뭵댢롦늗뉥껇꽩뎂롳뉗뉥닢롥늖덨덂롮늖멥

Push the string ",one,two,three,four,five,six,seven,eight,nine"

壹

Retrieve the first character from that string (but leave the string on the stack)

坼

Regular expression string-split. Result: ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]

⓶

Swap the top two elements (so the input is now on top)

掘

Get nth element from the list, leaving only the result on the stack.

Isn't it disallowed to use such languages?

@reg Why would it be?

For this reason http://meta.codegolf.stackexchange.com/a/1071/13171

@RegisteredUser: Sclipting is not designed for any particular challenge. It is, in fact, similar in goal to Golfscript.

In Java (7 and newer) ; 116 chars
public class A{public static void main(String[] a){System.out.print(Character.getName(48+Integer.parseInt(a[0])));}}

This program takes the input number as command-line argument, and outputs the letters in the console.
Example :

Input : 4
Output : DIGIT FOUR

I think the class doesn't need to be public; also, why not just call getName(a[0].charAt(0))? And you don't need a space after []

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.

R, 67 characters
scan(t='one two three four five six seven eight nine',w='')[scan()]

First part creates a vector containing the names, second part subset it according to user input (indices are 1-based in R).

PowerShell (71)
PS > "one,two,three,four,five,six,seven,eight,nine".split(",")[$(read-host)]

Works for valid inputs.

Javascript, 94 92 84 bytes
alert(['one','two','three','four','five','six', 'seven','eight','nine'][prompt()-1])

Explicit cast is useless : alert(['one','two','three','four','five','six', 'seven','eight','nine'][prompt()-1])

You can also abuse of split : alert('0one0two0three0four0five0six0seven0eight0nine'.split(0)[prompt()]) but that is the answer of @nderscore

C - 93 91 89 88 bytes (thanks Cool Guy)
main(x){scanf("%d",&x);write(1,5*--x+"one  two  threefour five six  seveneightnine",5);}

Old version with arguments instead of scanf:
main(int c,char**a){write(1,"one  two  threefour five six  seveneightnine"+*a[1]*5-245,5);}

Cryptic version (code-trolling?):
This one is somewhat longer but at least no space is wasted on spaces (only tabs and newlines ... and one space in function header).
main(int c,char**a){
    *a="039018342675onetwosixfourfivenineseveneightthree";
    c=*(*a+*a[1]-46)-39;
    write(1,c/3*(c-9)-*(*a+c/3-3)+60+*a,c/3);
}

Magic sequence 018342675 can be calculated as x+=6*!(x%3)-1;x%=9; but in the end I decided to use strings for everything.
Yet another version (different arrangement of numbers, easier to calculate position):
main(int c,char**a){
    *a="038146257onefourseventwofiveeightsixninethree";
    c=*(*a+*a[1]-49)-45;
    write(1,*a+c*4+!(c%3)-4,3+c%3);
}

Why not main(x){...} instead of x;main(){...} in the first program?

sed 90
It's really a trivial program (the brute force method); I wouldn't have bothered, except that it beats a surprising number of answers here.
s/9/nine/
s/8/eight/
s/7/seven/
s/6/six/
s/5/five/
s/4/four/
s/3/three/
s/2/two/
s/1/one/

Tcl, 61
Number entered as command line argument
lindex {- one two three four five six seven eight nine} $argv

Haskell 75
I know I'm a little late to the party, but thought I might as well:
fmap(words"_ One Two Three Four Five Six Seven Eight Nine"!!)readLn>>=print

Racket 159 bytes
(string-join(map(λ(x)(list-ref(list"zero""one""two""three""four""five""six""seven""eight""nine")(string->number(string x))))(string->list(number->string n))))

Ungolfed:
(define(f n)
  (string-join
   (map (λ (x)
          (list-ref [list "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine"]
                    (string->number(string x))))
        (string->list (number->string n)))))

Testing:
(f 10357)

Output:
"one zero three five seven"

17 bytes can be saved if number is sent enclosed in double quotes:
(define(f n)
  (string-join
   (map (λ (x)
          (list-ref [list "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine"]
                    (string->number(string x))))
        (string->list n))))

(f "10357")
"one zero three five seven"

It only has to work for 1-9 but nice answer! This could be extended to write out real english (10357 -> ten thousand three hundred fifty seven)

Wolfram, 11
There is a function for that of course: IntegerName

Factor, 11 bytes
a builtin: number>text.

Lexurgy, 79 bytes
a:
{\1,\2,\3,\4,\5,\6,\7,\8,\9}=>{one,two,three,four,five,six,seven,eight,nine}

Simple substitution.

Vyxal, 2 bytes
∆ċ

Try it Online!
Builtin.

POSIX SHELL: 68
Similar to Eric's Bash, without the bashisms (using set to mimick an array using $@) and eval to handle indirection (in bash this could just be echo ${!A} without the eval)
A=$1
set one two three four five six seven eight nine
eval echo \$$A

In bash you can just use $X instead of echo ${!X} as long as you use set :) If you use set, the curly braces actually cause nothing to happen while returning code 0.

@eric_lagergren - this is a proper posix implementation though -no bashisms allowed.  Even in bash though the ! is needed for variable indirection to convert the 1 stored in $A into a $1 variable.  Just eval-ing $A will try run 1, eval-ing $$A will try to run "one" ... the echo is just to print without a "command not found", just because I consider it bad form. (hopefully that's all - at least I don't know of any malicious binaries with spelled out number names)

The ! isn't needed http://i.imgur.com/tnivt32.png ... or at least, for whatever reason, I didn't need it. Adding echo removes the bash: xxxx: command not found but adds 4 .

@eric_lagergren - Yeah, that works ... in interactive mode only.  Now put it in an actual script. ... can't add it to an rc file because it clobbers your args.  Isn't working without real bash arrays fun?

As long as I'm not held accountable for it (except in perhaps a good way) I love writing hacky code :P

Rebol - 58
pick[one two three four five six seven eight nine]do input

Example from Rebol console:
>> pick[one two three four five six seven eight nine]do input
9
== nine

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()))

Ruby - 66
$><<%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.

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?

Ups!. I'll change it. Thanks @german_guy

@german_guy changed!

@ProgramFOX I'm sorry I don't understand you. Now it is using only swipl.

@rpax Ah, now I see. I thought you were only using bash now. I'm sorry.

Haskell : 89
do x<-readLn;print$[[],"one","two","three","four","five","six","seven","eight","nine"]!!x

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 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 Thanks. didn't knew about it. I'm not too good in python.

PHP 5.5 (62)
<?=[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)];

///, 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.

@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.

http://slashes.tryitonline.net/#code=L18vXC9cLy8vMC96ZXJvXzEvb25lXzIvdHdvXzMvdGhyZWVfNC9mb3VyXzUvZml2ZV82L3NpeF83L3NldmVuXzgvZWlnaHRfOS9uaW5lLwowIDEgMiAzIDQgNSA2IDcgOCA5&input=

@MartinEnder So that is the reason I've had problems with forward slashes (/) in the past...

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".)

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?

Yes. ideone.com test. @Eʀɪᴋ ᴛʜᴇ Gᴏʟғᴇʀ

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Return the flipped version of a number
When a number is shown on a calculator, it's possible to consider what various transformations of that number would look like. For example, on a seven-segment display, 2 is shown like this:

And when flipped horizontally it looks like this:

As such, the mirror image of 2 is 5.
The task in this challenge is to take a single-digit number, and return the number that's its mirror image (if possible). If its mirror image does not look like a number, return the number rotated 180 degrees (if possible). If neither of these are the case, return -1.
Here's the full list of inputs and outputs your program needs to handle:
Input   Output
0       0
1       -1
2       5
3       -1
4       -1
5       2
6       9
7       -1
8       8
9       6

As a code-golf challenge, the shortest code wins!

You can submit your own answer to your question, so feel free to add it.

Okay, I will do that. Thanks

I disagree with your last point -- a 1 on a 7 segment display would simply be flipped to the other side, so 1 should nap to 1.

You should specify I/O. Do you want a function, a program or anything specific?

why wouldn't 8 and 0 return -1?

I am confused about how to flip each digit. If 2 becomes 5, then 6 should become backwards 9, not 9. But if 6 becomes 9, then the flip is just a rotation, so 2 becomes another 2, not 5.

@kernigh I think it's meant to be a reflection across a horizontal axis.

@Cory But the question states that 9 and 6 should flip to 6 and 9. That is not a reflection across the horizontal axis.

6, 9 rotated 180 deg, 2, 5 flipped horizontally, and 1, 3 in fact are reflections of themselves across the vertical axis.

The translations defined in the question are not consistent at all. Why do 2 and 5 flip, but 3 doesn't?

@Rynant Yeah, 1, 3, 6, and 9 really throw my definition off (foolish positive bias!). I'll pay more attention from here on out. Fortunately, everything but 4 is explicitly spelled out in the challenge. So the rule is consistent, but with an extra layer of complexity.

I noticed a curious fact about the switchable numbers: they form opposite binary patterns, i.e. 2=010, 5=101. 6=0110, 9=1001. Can anyone use this fact in their solution?

@JackAidley: I guess since the problem is so trivial and, in fact, tailored to IndexOf-type methods on strings I doubt this will lead to significant savings.

Agree. 6 rotated 180 degrees becomes 9 but 2 and 5 rotated 180 degrees become itself again. This should be restated as flipped or rotated version of a number, and 1 should be included in

3 should be flipped to E

Maybe your example should be 6 and 9 because 5 could be flipped horizontally or vertically to become 2

I've gone and edited the specification to match the answers. Hopefully this challenge can be reopened now.

Haskell - 43 31
43 characters without anything fancy.
f 0=0
f 8=8
f 2=5
f 5=2
f 6=9
f 9=6
f _= -1

Got it down to 31 characters by making it a partial function.
f=([0,-1,5,-1,-1,2,9,-1,8,6]!!)

I laughed. Have a +1.

+1 For using Haskell to do exactly what the spec. says!

I don't think you need f= for the second solution as it is a valid expression

GolfScript, 15 14
I read the spec again and found that the input must be a string.
"0.5..29.86"\?

To run:
echo -n 2 | ruby golfscript.rb a.gs

Old version(which has integer input):
[0.5..2 9.8 6]?

The newer one(14 byte) is somewhat inspired by the CJam answer by aditsu.

Can't believe I didn't think of that...

PowerShell - 27
'0 5  29 86'.indexof($args)

Python 2.x - 28
'015..29.86'.find(`input()`)

Python 2.x, specifically.

With Python 3, you could remove the ```s and save 2 chars.

This is a snippet, not a full program!

JavaScript 37 36
alert("0_5__29_86".search(prompt()))

use .search() and save a byte.

@IsmaelMiguel Nice one, Thanks!

BEFUNGE 93 - 18 14 20 Bytes
I guess the commentators are right, though Befunge being a 2d language lines are kinda different. Still, in this instant, the commentators are right.
&1g01g-.
! &  #* )'

Steps:
&

Reads input as a numerical value x, and pushes it on the stack.
1g

Gets the character value c (so, like '!' = 33, or '*' = 42. An empty cell = 32) at position x, 1.
01g-.

Reads the character value of cell 0,1 (33), subtracts it from c, and outputs it as a numerical value.

Quite nice. Have a +1.

Please correct the length: it's 20 bytes

You've actually been counting your bytes wrong. You used 19 bytes. We count newlines and spaces. But if you switch to Befunge 98, you can save one; change 1st line to: &1g'!-.

CJam, 20 bytes
q25691347`"5296W"er~

Try it online.
Output
$ for i in {0..9}; { cjam <(echo 'q25691347`"5296W"er~') <<< $i; echo; }
0
-1
5
-1
-1
2
9
-1
8
6

How it works
q          " Read from STDIN. The leaves a string on the stack.            ";
25691347`  " Push the string '25691347'.                                   ";
"5296W"    " Push the string '5296W'.                                      ";
er         " Perform character transliteration.                            ";
~          " Evaluate the result. Examples: '2' returns 2, 'W' returns -1. ";

JavaScript (ECMAScript 6) 25
x=>'1060039097'[x]-(x!=6)

JavaScript (ECMAScript 5) 43
function f(x){return'1060039097'[x]-(x!=6)}

UPDATE: edc65 has suggested a much better technique. toothbrush has suggested a much better language. At this point, my primary contributions are debugging and gumption.

If you change it to ECMAScript 6 (supported in Firefox), you could simply do x=>[0,-1,5,-1,-1,2,9,-1,8,6][x].

At first, I nearly posted function(x)[0,-1,5,-1,-1,2,9,-1,8,6][x], also thanks to Firefox. I wasn't going to win anyway, so I decided I'd just stick with the highest-compatibility answer. If I start switching languages for brevity, then I'll eventually start defining my own language for every challenge I do. But I'll go ahead and mention the ECMAScript 6 version anyway, since you suggested it

Same concept but shorter (bye bye commas): x=>'106003907'[x]-(x!=6)

@edc65 You know, I'd wanted to use a string, and I had completely blanked on the fact that I could coerce the result back to a number. A bizarre lapse. Yet I still wouldn't have come up with -(x!=6). Thank you.

you don't need f= unless you are calling f recursively or the question explicitly requires a function with a specific name

@Cyoce Good point.

Java - 49
long f(int a){return(0x790a300601L>>(a*4)&15)-1;}

Here, 0x790a300601 is a value stuffed with the desired outputs, with one added to make them positive. The values are stored in nibbles within the value, so a bit of shifting and masking is required to pop them out.
Java - 100 (fun option)
int f(int a){Random r=new Random(0x2000A2F47D6Fl);int b=0;for(;a>=0;a--)b=r.nextInt(11)-1;
return b;}

Not the smallest option, but a bit of fun. I found a random seed that produces the correct values when called X times (where 0 >= X <= 9).

Clever. Have a +1

bash 29
tr 1-9 x5xx29x86|sed s/x/-1/g

e.g.
$ echo 0 1 2 3 4 5 6 7 8 9 | tr 1-9 x5xx29x86|sed s/x/-1/g
0 -1 5 -1 -1 2 9 -1 8 6

You can omit the ' around the sed expression.  Also I think you can omit the g because the spec only supplies one digit at a time

Thanks. It's just in the example, the submission itself doesn't use '. Liking the g for longer input!

Kona - 29
This function returns the element x from the array 0 -1 5...
f:{0 -1 5 -1 -1 2 9 -1 8 6@x}

Examples:
> f 2
  5
> f 5
  2
> f 8
  8

Is a vector by itself really allowed?

@TheRare: Hmm, it does say "algorithm" so I suppose not. I'll change it and make it more like yours...

Seems better, have a +1.

JavaScript 36 37 41
alert('0x'+'65b558f5ec'[prompt()]-6)

as ES6 function - 27:
f=v=>'0x'+'65b558f5ec'[v]-6

28: f=v=>~-[1,,6,,,3,10,,9,7][v]

@nderscore You just love improving people's codes, don't you?

@TheRare I'm just on a quest to find the shortest javascript code. :) If someone else has already posted a good answer, it makes more sense to me to find optimizations in it rather than post a new answer that's almost a duplicate. I'm not here to compete, just to cooperate towards achieving this goal.

@nderscore I have the same mentality as long as my idea is similar enough. Anyways, nice one.

@nderscore You really gave me a motivation. I'm not sure if I can make it shorter, but I'll try :)

@core1024 clever method!

Sclipting, 11 characters
걄럣뉥밈결⓷方分결剩貶

Finally I have found a Windows computer with Visual Studio installed to build its interpreter. And it has defeated my GolfScript code easily.
It reads 18453063256\11\?/11%( in GolfScript.

Interesting, but your GolfScript answer still wins. Unless the question states otherwise, length is measured in bytes.

@Dennis This was my 3rd or 4th answer on this site. I didn't know. And I think APL is an exception.

@Dennis And most people don't like Sclipting. :)

Not really an exception, we just let people choose their encoding. This answer would score 22 bytes, since that's its size using UTF-16. APL uses only 256 different characters, and there's an APL code page where once character is exactly one bytes.

@Dennis Ah, you are right.

APL (Dyalog Extended), 22 bytes
⊢⌷{1-⍨⎕A⍳'BAGAADKAJH'}

Explanation:
⊢⌷{1-⍨⎕A⍳'BAGAADKAJH'}
      ⎕A⍳'BAGAADKAJH'     ⍝ numeric vector 2 1 7 1 1 4 11 1 10 8
   1-⍨                    ⍝ decrement:     1 0 6 0 0 3 10 0  9 7
⊢⌷                        ⍝ value at index ⍵ in the lut

Try it online!

there's an easy -1 byte here.

commute, I see.

1-⍨⎕A⍳⌷∘'BAGAADKAJH'

J - 28 27 bytes
You know what I like? Simplicity (28 bytes). Note that in J, _1 is negative one (-1).
f=:{&0 _1 5 _1 _1 2 9 _1 8 6

Add a little complexity and you have 27 bytes.
f=:-{&0 2 _3 4 5 3 _3 8 0 3

Example:
   f 2
5
   f 6
9
   f 5
2
...

CJam - 14
Input/output version:
"0 5  29 86"q#

Stack version (assumes the number is on the stack):
[0W5WWY9W8 6]=

Try them at http://cjam.aditsu.net/

There's no Wikipedia article about CJAM, and the link just goes to a blank fiddler.  Where would you find information about the language and its established releases?

Looks like this is it: http://sourceforge.net/projects/cjam/

@Panzercrisis http://cjam.aditsu.net/ has "CJam" linked to the sourceforge page

Perl, 27 26
Count includes the p flag
y/2569/5296/,s/[1347]/-1/

Usage:
$ echo 7 | perl -pe y/2569/5296/,s/[1347]/-1/
-1

Wait, did Perl just beat J? :)

+1 I was going to post y+0-9+9a4aa70a13+;$_=9-hex, which is the same length, but your is more original ;)

@core1024 : And it just got shorter ;)

It didn't: echo 1 | perl -pe y/2569/5296/,s/[347]/-1/

@core1024 : I misread the specs, should be fixed now. It's still shorter than the J solution.

There really is no concise way to do this in J, as values are strictly typed and numbers can't match strings.

@TheRare : I don't think it'll get much shorter in Perl than this either.

I actually clocked around triple the characters doing it in this style. Have a +1 for the nice idea.

perl -pE "y/2569/5296/or$_=-1" :)

@alexander-brett : won't work for 0

Sure, could put the 0 in the 'y///' I guess?

ECMAScript 6, 24
f=x=>~-++'0n5nn29n86'[x]

Using normal JavaScript it would be 33:
alert(~-++'0n5nn29n86'[prompt()])

Marbelous 34 bytes
}0
=6=9=2=5=0=8?0
+3-3+3-3....--

It's not the shortest solution, but it's not the longest either.
How it works
}0 spawns a marble representing the first command line input. This marble drops down the next tick, onto the =6 cell. =6 is a comparison cell, it pushes any marble with value 6 down and all others to the right. This line-up of comparison cells pushes marbles right until they equal a desired value. 0 and 8 just fall through and get printed when tehy fall off the bottom of the board, 6 and 2, and 9 and 5 first get 3 added to them, subtracted from them respectively. If a marble doesn't equal any of the desired values, it lands on the ?0 cell, which turn any marble into a 0 marble1. This marble then gets decremented and falls off the board.
1 A ?n marble technically turns any marble into a marble between 0 and n. This has the nice side effect that ?0 turns anything into 0.

MATLAB - 35
I would wrap this in a function with n as the only parameter.
f=[0,-1,5,-1,-1,2,9,-1,8,6];
f(n+1)

35 characters.

TI-BASIC, 24 22
-1+int(11fPart(11^Ans.0954191904

This encodes the possible outputs in a lookup table stored as a base-11 floating point number; the (N+1)th base-11 digit after the decimal point is extracted from the table to get the value of the inverted digit. In base 11 the number is .106003A097, and the digits of this less one are exactly 0,-1,5,-1,-1,2,9,-1,8,6.
edc65's trick of subtracting one in the case of 6 leads to this 24-byte solution, where ⑩^( is a single one-byte token:
-(Ans≠6)+int(10fPart(.1060039097⑩^(Ans

The string approach is 29 bytes:
-(Ans≠6)+expr(inString("1060039097",Ans+1,1

The array approach (which Ypnpyn also took) is 30 bytes, assuming the number is stored in X:
{1,0,6,0,0,3,10,0,9,7}-1:Ans(X+1

24 -> 22: Removed two extra digits of precision in the magic constant.

This can almost certainly be golfed to 19, and possibly to 18; however, I need to search for the correct numbers.

C - 47 bytes [was 48 Bytes]
f(i){return(int[]){1,0,6,0,0,3,10,0,9,7}[i]-1;}

To add I/O (which other answers didn't always) for 86 bytes:
main(i){i=(int[]){1,0,6,0,0,3,10,0,9,7}[getchar()-48]-1;i<0?puts("-1"):putchar(i+48);}

Wow, I had no clue inline array literals like this were a thing. Very nice first answer, and welcome to PPCG! (There is no need to add I/O function submissions are perfectly valid.)

05AB1E, 13 bytes
0®5®®Y9®8 6¹@

Try it online!
-3 thanks to Emigna.
Explanation:
0®5®®Y9®8 6¹@ Takes an integer from STDIN.
0®5®®Y9®8 6   Push 0, r=-1, 5, r=-1, r=-1, Y=2, 9, r=-1, 8, 6.
           ¹  Push first input item.
            @ Pop and push the 0-indexed stack item at the respective index.

0®5®®Y9®8 6¹@ should work as well.

@Emigna I had no idea, thanks!

Good thinking with @. Not often you see that used :)

@Emigna A byte shorter than )¹è or )sè.

Python - 34
f=lambda n:ord("A@F@@CJ@IG"[n])-65

33 f=lambda n:ord(" "[n])-3 working with space http://www.codeskulptor.org/#user34_Q7NbNvQy55_0.py

You might want to explain how and why this works

Using the ascii table http://www.asciitable.com/ the white spaces chosen are printable in python. it actually looks something like �	 It's minus 3 for the reason that -1 leaves a null character which is no good, and minus 2 leaves a line feed which is reserved in python

Java, 58 59
int f(int i){int[]a={1,0,6,0,0,3,10,0,9,7};return a[i]-1;}

OR
int f(int i){return new int[]{1,0,6,0,0,3,10,0,9,7}[i]-1;}

You can make your code a bit shorter if you add 1 to each value in array and after [i] substract 1.

@Barteks2x Good point; thanks

C - 117 108 106 77 76 bytes
a[]={1,0,6,0,0,3,10,0,9,7};main(int c,char**b){printf("%d",a[*b[1]-48]-1);}

Not the best language for golfing, but oh well...
Compile with gcc progname.c -o progname.  (Ignore the warnings, or add -include stdio.h to the compile command.)

Usage: ./progname <number>

EDIT
As per @bebe's suggestion, here is an example that takes the input from STDIN instead:
C - 68 51 bytes
main(){printf("%d","106003:097"[getchar()-48]-49);}

using d=*b[1]-48 could be a good idea

@bebe Ah yes, thanks!

main(){printf("%d",(int[]){1,0,6,0,0,3,10,0,9,7}[getchar()-48]-1);} sorry for bothering you this much but i find this a bit shorter.

You can save another character by making the array global so you don't need the cast. a[]={1,0,6,0,0,3,10,0,9,7};main(){printf("%d",a[getchar()-48]-1);}

main(){printf("%d","106003:097"[getchar()-48]-49);} 51 bytes

@bebe Wow, you are a lot better golfer than me!!

JavaScript 42 37
Run it on the console of your browser
alert(~-[1,,6,,,3,10,,9,7][prompt()])

J (24, function)
(the input panel isn't playing nice. Paste the following in a python interpreter and my answer shall be revealed:)
print "f=:{&(_3+3 u:'^C^B^B^E^L^B^K\t')"

Clojure - 36
#(case % 2 5 5 2 6 9 9 6 0 0 8 8 -1)

Perl, 22B
perl -pe "y/25690/52960/or$_=-1"
Based off https://codegolf.stackexchange.com/a/32012/19039, but shorter. 1B penalty for -p.

Turtlèd, 40 bytes (noncompeting)
!.(3'1)(4'1)(1l'-)(2'5l)(5'2)(6'9l)(9'6)

Try it online!
Explanation
!                                          take input
 .                                         write first char of input to cell
  (3'1)                                    if cell is 3, write 1
       (4'1)                               if cell is 4, write 1
            (1l'-)                         If cell is 1, move left and write -
                  (2'5l)                   If cell is 2, write 5 and move left
                        (5'2)              If cell is 5, write 2
                             (6'9l)        If cell is 6, write 9 and move left
                                   (9'6)   If cell is 9, write 6

Jelly, 14 bytes
ị“-5--29-860”V

Try it online!
Explanation:
ị“-5--29-860”V Takes argument as an integer.
 “-5--29-860”  "-5--29-860" (1-indexed string).
ị              Return the xth char of the string above (y) (x=argument).
             V Eval. - is the same as -1.

ịV = žh‡ in 05AB1E

PHP, 48 39 bytes
Thanks to Jörg Hülsermann
<?=[0,-1,5,-1,-1,2,9,-1,8,6][$argv[1]];

Try it online!

Older versions
$m=-1;echo [0,$m,5,$m,$m,2,9,$m,8,6][$argv[1]];

Try it online!

Hey, thanks! Even better, should I post?

Vyxal, 16 bytes
kd`0u5uu29u86`⇿ₑ

Try it Online!
Simply push the digits 0 to 9, push the string 0u5uu29u86 (the mapping of each number - u pushes -1 in Vyxal), transliterate and evaluate as Vyxal.

Excel, 31 bytes
=MID(1060039097,A1+1,1)-(A1<>6)

Python 3.11 - 24
lambda x:"0.5..29.86"[x]

Based on this Python 2.x answer by Willem.

Python - 92
f=lambda x:x if x in(0,8)else(5if x==2 else(2if x==5 else(6if x==9 else(9if x==6 else -1))))

Usage:
>>> f(2)
5
>>> f(3)
-1

def f(x): will make it a byte shorter.
Also "[a,b][x==5]" is shorter then and equivalent to "a if x==5 else b"

Also, a small change would be to put the if x==9 last and say x>8 instead, saving a character.

@Pinna_be: You’re forgetting the return.

Python - 73 bytes
r=[2,5,2,9,6,9,8,8,0,0]
f=lambda x:-1 if x not in r else r[r.index(x)+1]

Or, for one digit numbers only :
r=[0,-1,5,-1,-1,2,9,-1,8,6]
f=lambda x:r[x]

why not altogether f=(lambda x:[-1,-1,5,-1,-1,2,9,-1,8,6][x])(x)

43 def f(x):print[-1,-1,5,-1,-1,2,9,-1,8,6][x]

Java, 75
int f(int i){return i>8?6:i>7?8:i>6?-1:i>5?9:i>4?2:i>2?-1:i>1?5:i>0?-1:0;}

i>8:-1 will return -1 for input 9 when it should return 6, won't it?

@corsiKa Indeed.

PowerShell 32
(0,-1,5,-1,-1,2,9,-1,8,6)[$args]

F# - 37 bytes
let f n=[0;-1;5;-1;-1;2;9;-1;8;6].[n]

Usage:
> f 2
val it : int = 5
> f 9
val it : int = 6
> f 4
val it : int = -1

Fails for 0 and 8

I missed that in the rules, thanks!

TI-BASIC, 35
{1,0,6,0,0,3,10,0,9,7}→L1:L1(X+1)-1

Previous attempt, 42:
6(X=2)+3(X=5)+10(X=6)+9(X=8)+7(X=9)-1+(X=0

30 bytes: {1,0,6,0,0,3,10,0,9,7}-1:Ans(X+1

C++ 85
Uses nested ternary statements.
int main(){int a;cin>>a;a=(a==2)?5:(a==5?2:(a==6?9:(a==9?6:(a%8==0?a:-1))));cout<<a;}

Doesn't C++ inherit the abuse of integers for Booleans of C?

@PeterTaylor Yes C++ accepts integers, but I don't want 'a' modified until the end.

No need to modify a. I was thinking that (a==X)?Y:Z can be (a-X)?Z:Y to save a few bytes.

Which compiler are you using? I can't find a gcc version that accepts that without #include <iostream> and std::.

Bash 26
bc<<<`tr 0-9 106003A097`-1

eg.
for i in {0..9}; do echo $i|
  bc<<<`tr 0-9 106003A097`-1
done
0
-1
5
-1
-1
2
9
-1
8
6

Python3: 47
A very basic implementation, that accepts a input and translates accordingly.
print([0,-1,5,-1,-1,-1,9,-1,8,6][int(input())])

PEP8 is of course sacrificed for the sake of characters. This doesn't come close to rivaling the other Python solution near the top. However, as my first golf, I don't think it's that bad :).

This could be written print[0,-1,5,-1,-1,-1,9,-1,8,6][input()] in Python 2. Also one could increase all the numbers by 1 to save one character.

Zozotez LISP 87
((:'f(\(k n v)(? k(?(=(a k)n)(a v)(f(d k)n(d v)))'-1)))'(0 2 5 6 8 9)(r)'(0 5 2 9 8 6))

This assumes you start it by seeding one of the REPL supplied so the printing actually is done by Without a driver/REPL you need 3 chars extra:
(p((:'f(\(k n v)(? k(?(=(a k)n)(a v)(f(d k)n(d v)))'-1)))'(0 2 5 6 8 9)(r)'(0 5 2 9 8 6)))

Batch - 79
set /aa=%1+1&for /f "tokens=%a%" %%1 in ("0 -1 5 -1 -1 2 9 -1 8 6") do echo>%%1

Used as filename.bat number, output is as a file with the name of the correct number.

Haskell (full program), 63
main=interact$maybe"-1"(:"").(`lookup`zip"025689""052986").head

Call main, and whatever character your input starts with gets used. Anything that isn't '0', '2', '5', '6', '8', or '9' prints "-1". Unfortunately show wraps characters in single quotes, so the output wouldn't have been consistent, so I had to use (:"") (or (:[])).

Ruby, 30 bytes
What, no Ruby solution yet?
p'0 5  29 86'.index($*[0])||-1

Takes the input as a command-line argument.

Pyth - 16 bytes
x[ZZ5ZZ2 9Z8 6)Q

Doesn't really count because Pyth was created after this was posted, but it's still pretty neat.

@ThomasKwa Fixed.

C (gcc), 46 27 bytes
f(i){i="BAGAADKAJH"[i]-66;}

Try it online!

dimwit 24 23 bytes (non-competing)
Edit: removed end bracket, as it is not necessary
Another question that I thought could be good for working on the language with...
R2,5,6,9,[1-7]}5,2,9,6,-1

Explanation:

R - map replace
2,5,7,9,[1-7]} - the searches. Since 2, 5, 6, and 9 are checked first, 1-7 can be used and will simply check if it's 1, 3, 4, or 7. 0 and 8 will therefore stay the same.
5,2,9,6,-1 - the replacements. So 2 is replaced by 5, 5 is replaced by 2, etc.

Try it Here

Thunno 2, 14 bytes
6 8u9yuu5u0K$i

Try it online!
¿£Ṣƥ*ðdiṅ×Ɗ€¿i

Try it online!
Explanation
6 8u9yuu5u0K$i  # Implicit input
6 8u9yuu5u0     # Push 6,8,-1,9,2,-1,-1,5,-1,0
           K    # Wrap the stack (reversed)
            $i  # Index the input in
                # Implicit output

¿£Ṣƥ*ðdiṅ×Ɗ€¿i  # Implicit input
¿£Ṣƥ*ðdiṅ×Ɗ€¿   # Push compressed list
                # [0,-1,5,-1,-1,2,9,-1,8,6]
             i  # Index the input in
                # Implicit output

J, 18 bytes
_1".{&'0x5xx29x86'

Attempt This Online!
_1".{&'0x5xx29x86'
    {&'0x5xx29x86'  NB. index into a string literal
_1".                NB. eval the result using _1 as a default value

JavaScript (Node.js), 25 bytes
x=>'0x'+'106003a097'[x]-1

Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

authors: Алексей Горин

authors: Данияр Мукаш уулу

sort: votes


text:
Newtons Method by Recursive Quines
Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's Method, and output the source code for the following iteration (which must be able to do the same).
Newton's method is fairly exhaustively described on Wikipedia
To calculate square root 2 using Newtons method, you:

Define f(x) = x^2 - 2
Define f'(x) = 2x
Define x[0] (the initial guess) = 1
Define x[n+1] = x[n] - (f[n] / f'[n])

Each iteration will move x[n] closer to the square root of two. So -

x[0] = 1
x[1] = x[0] - f(x[0])/f'(x[0]) = 1 - (1 ^ 2 - 2) / (2 * 1) = 1.5
x[2] = x[1] - f(x[1])/f'(x[1]) = 1.5 - (1.5 ^ 2 - 2) / (2 * 1.5) = 1.416666667
x[3] = x[2] - f(x[2])/f'(x[1]) = 1.416666667 - (1.416666667 ^ 2 - 2) / (2 * 1.416666667) = 1.414215686
and so on

Your program will:

Calculate x[n] where n is the amount of times the program has been run
Output the source code to a valid program in the same language which must calculate x[n+1] and satisfy the same criteria of this question.
The first line of the source code must be the calculate result, properly commented. If the source requires something particular (such as a shebang) on the first line, the result may be put on the second line.

Note that

Your program must use an initial guess of x[0] = 1
The Standard Loopholes apply
Any in-build power, square root or xroot functions are forbidden
Your program must not accept any input whatsoever. It must be entirely self contained.

Your score is the size of your initial program in UTF-8 bytes. The lowest score wins.

Do we have to define the functions, or can we simplify by writing x = x-(x*x-2)/(2*x)?

That simplification looks valid to me. As long as it performs the calculation using Newton's Method

Does the program output the approximation, or just the source code? Can it take as its input the previous solution?

It has to output the approximation (commented) on the first line, with the source code for the next iteration. The approximation may be preceded by a shebang if the language requires it. The program (nor the program it produces) must not accept any input.

Common Lisp, 223 95 68 66
(#1=(lambda(x p)(format t"~S~%~S"p`(,x',x,(+(/ p 2)(/ p)))))'#1#1)

Now that I read the problem statement more carefully (thanks, primo!) I noticed that the first line must be the result of calculation, not that it needs to contain the result. Thus, I think my earlier attempts did not quite follow the rules. This one should.
Example use (SBCL 1.1.15):
$ sbcl --script nq.lisp | tee nq2.lisp
1
((LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 '(LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P))))) 3/2)
$ sbcl --script nq2.lisp | tee nq3.lisp
3/2
((LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 '(LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P))))) 17/12)
$ sbcl --script nq3.lisp | tee nq4.lisp
17/12
((LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 '(LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P))))) 577/408)
$ sbcl --script nq4.lisp | tee nq5.lisp
577/408
((LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 '(LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 665857/470832)
$ sbcl --script nq5.lisp | tee nq6.lisp
665857/470832
((LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 '(LAMBDA (X P) (FORMAT T "~S~%~S" P `(,X ',X ,(+ (/ P 2) (/ P)))))
 886731088897/627013566048)
$

I've been mostly testing with CCL, but it works similarly with both SBCL and CLISP.

This is more like I was expecting. +1

Python 53 bytes
Saved 7 bytes due to @Mukundan.
x=1.
o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

I've simplified the formula slightly, using the following substitutions:
  x-(x²-2)/(2x)
= (2x²)/(2x)-(x²-2)/(2x)
= (2x²-x²+2)/(2x)
= (x²+2)/(2x)
= (x+2/x)/2
= x/2+1/x

I hope that's not an issue.
The program proceeds in the following manner:
$ python newton-quine.py
x=1.5
o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

$ python newton-quine.py
x=1.41666666667
o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

$ python newton-quine.py
x=1.41421568627
o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

$ python newton-quine.py
x=1.41421356237
o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

etc.

I don't know if this is legal or not, but you can shorten your initial code to g="x=%s;o=%r;print o%%(x/2+1/x,o)";print g%(1.5,g) @ 50 chars.

@Trimsty I think it's slightly problematic that 1) it doesn't actually calculate the first iteration, and that 2) the first line doesn't contain the current result. As I understand the problem description, both the original program and later generations should satisfy these criteria.

you can shorten you code by 7 bytes by using exec x=1. o='print"x=%s\\no=%r;exec o"%(x/2+1/x,o)';exec o

@Mukundan that's a great improvement, thanks!

CJam, 20 bytes
1
{\d_2/1@/+p"_~"}_~

Try it online.
Output
$ cjam <(echo -e '1\n{\d_2/1@/+p"_~"}_~'); echo
1.5
{\d_2/1@/+p"_~"}_~
$ cjam <(cjam <(echo -e '1\n{\d_2/1@/+p"_~"}_~')); echo
1.4166666666666665
{\d_2/1@/+p"_~"}_~
$ cjam <(cjam <(cjam <(echo -e '1\n{\d_2/1@/+p"_~"}_~'))); echo
1.4142156862745097
{\d_2/1@/+p"_~"}_~
$ cjam <(cjam <(cjam <(cjam <(echo -e '1\n{\d_2/1@/+p"_~"}_~')))); echo
1.4142135623746899
{\d_2/1@/+p"_~"}_~

How it works
1       " Push the initial guess.                                                 ";
{       "                                                                         ";
  \d    " Swap the code block with the initial guess and cast to Double.          ";
  _2/   " Duplicate the initial guess and divide the copy by 2.                   ";
  1@/   " Push 1, rotate the initial guess on top and divide.                     ";
  +p    " Add the quotients and print.                                            ";
  "_~"  " Push the string '_~'.                                                   ";
}       "                                                                         ";
_~      " Duplicate the code block (to leave a copy on the stack) and execute it. ";

Well that's impressive. +1

ECMAScript 6, 38 36
(f=x=>"(f="+f+")("+(x/2+1/x)+")")(1)
(f=x=>"(f="+f+")("+(x/2+1/x)+")")(1.5)
(f=x=>"(f="+f+")("+(x/2+1/x)+")")(1.4166666666666665)
(f=x=>"(f="+f+")("+(x/2+1/x)+")")(1.4142156862745097)
(f=x=>"(f="+f+")("+(x/2+1/x)+")")(1.4142135623746899)

JavaScript, 51
(function f(x){return "("+f+")("+(x/2+1/x)+")"})(1)

This is the same as the above, for older browsers.

Sometimes I'm just amazed how simple javascript can make things. +1

This seems to be lacking any sort of output (print, putstr, console.log, etc.).

@primo - When JavaScript is run in a console, the returned value is automatically printed.

@Derek朕會功夫 Very many languages can be run as REPL - this is an expression, and not a complete program. See: Standard “loopholes” which are no longer funny.

@primo - This is a complete program. The compiler can compile and execute this with no problem. What's considered a snippet is a piece of code that needs extra codes in order to make it work. One such example can be found in your link. When Zaq's answer is run in a console (the environment), it compiles and needs no extra code around it. The automatically returned string is implemented right in the "environment", so no rules are violated, and indeed this isn't any kind of loophole.

@Derek朕會功夫 The 'interactive console' provided with many browsers is an REPL: "a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user; a program written in a REPL environment is executed piecewise." Run as a script with a command line JS interpreter, this 'program' outputs nothing. By the standard you suggest, code written in any language for which an REPL even exists need not output anything.

@primo - What are making you to think those "expressions" do not output anything? In this specific environment, it will output anything the "expression" has returned. Same goes to things like "print(text)". Depending on which environment you are executing your code in, you code behaves differently.

@Derek朕會功夫 The problem description specifically asks for a program - in several places. The program supplied does nothing. Witness: http://i.stack.imgur.com/Te7Vf.png The above is an expression that evaluates to an expression. It has merit of its own, but it is not a program.

@primo - It did does something. It caused the environment (the console) to generate an output on the screen. This is a legit program, not simply an expression.

Can both of you give it a rest? You're filling my inbox with your little spat.  This question/answer hasn't had any activity in 2 months and I don't really care who of you is right.

Lua 129
Probably way too long, but the Lua quine sucks because the nested [[ ]] is a deprecated feature. But it works regardless:
x=1.0;x=x/2.+1./x;l=[[io.write('x=',x,';x=x/2.+1./x;l=[','[',l,']','];',l)]];io.write('x=',x,';x=x/2.+1./x;l=[','[',l,']','];',l)

It's a bit nicer to see if you add newlines instead of colons:
x=1.0
x=x/2.+1./x
l=[[io.write('x=',x,'\nx=x/2.+1./x\nl=[','[',l,']','];',l)]];io.write('x=',x,'\nx=x/2.+1./x\nl=[','[',l,']','];',l)

J - 102 88 bytes
This is as horrible as I'm at making quines (I will probably revise this when I get better ideas). J's floats are limited to 5 decimal places, but by replacing first line with x=:1x it would be a fraction with infinite precision.
Edit 1: I got better idea. Also added the explanation.

x=:1
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'x=:((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'''

First few iterations:
x=:1.5
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'x=:((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'''

x=:1.41667
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'x=:((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'''

x=:1.41422
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'x=:((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'''

Explanation
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'x=:((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:)'''
((3&{.,[:":(x%2)+1%x"_),:3&}.,],{:,{:) The quine-function
                         3&}.,],{:,{:  Build the second row
                         3&}.          Get everything but the first 3 characters from the string
                             ,]        Get the whole string and concat
                               ,{:     Get the last item (') and concat
                                  ,{:  -||-
 (3&{.,[:":(x%2)+1%x"_)                Build the first row
       [:":(x%2)+1%x"_                 Calculate x/2 + 1/x (stolen from Pythoneer) and stringify
  3&{.                                 Take the first 3 characters from the string (x=:)
      ,                                Concatenate 'x=:' and the result
                       ,:              Concatenate the two rows

I actually love how simple this program is (for serious).

If I get more time, I'm going to see if I can modify the above for Kona.

@KyleKanos At least the digit-rotation-thingy was similar enough, but I don't know Kona. Good luck! :)

1%x is the same as %x. Instead of (x%2)+1%x, you can do (%&2+%)x.

Ruby, 65
x=1.0
puts"x=#{x/2+1/x}",<<'1'*2,1
puts"x=#{x/2+1/x}",<<'1'*2,1
1

As too often happens, this is almost a straight port of the Python solution.

Perl 5, (-M5.01) 58 bytes
$x=1.;$_=q(say'$x='.($x/2+1/$x).qq(;\$_=q($_);eval));eval

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Are you in the biggest room?
Introduction
You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell from just eyeballing your co-workers' offices when you stop by. The only way to figure this out is to examine the blueprints for the building...
Your Task
Write a program, script, or function that takes a floor plan for your building and indicates whether your office is the largest. The floor plan is easy to read because the building is an n by n square.
The input will consist of n+1 \n-delimited lines. The first line will have the number n on it. The next n lines will be the floorplan for the building. A simple example input:
6
......
.  . .
.X . .
.  . .
.  . .
......

The rules for the floorplan are as follows:

. (ASCII 46) Will be used to represent walls.   (Space [ASCII 32]) will be used to represent open space.
You are represented by an X (ASCII 88). You are in your office.
The floorplan will be n lines, each with n characters.
The building is totally surrounded by walls on all sides. This implies that the 2nd line of input (the first line of the floorplan) and the last line of input will be all .s. It also implies that the first and last characters of every floorplan line will be .s.
An office size is defined as the sum of adjacent spaces (contiguous by moving in 4 directions, N, S, E, W, without going through a wall).
For the purpose of office size, the X representing you counts as a   (open space)
4 <= n <= 80

You should output whether or not your office is strictly bigger than all the other offices. The output can be anything that unambiguously signifies True or False in your programming language of choice and adheres to standard conventions of zero, null, and empty signifying False. True implies your office is strictly the biggest.
Sample output for above input:
1

Because your office is 8 square feet, and the only other office is 4 square feet.
I/O Guidelines

The input may be read from stdin, and answer output to stdout.

Or

The input may be a single string argument to a function, and answer be the return value of that function.

FAQ

The entire building consists of walls and offices.
The building is only one floor
There is guaranteed to be an X in the input, but there are not guaranteed to be any spaces. You could have a 1x1 office and the rest of the building is walls (You have the biggest office! hooray!).

Other Example
10
..........
.   .  . .
.  .   . .
.  .   . .
. ..   . .
..       .
..........
.      X .
.        .
..........

Here there are 3 offices, your south office is rectangular, the northwest office is a triangle(ish) and the northeast office is strangely misshapen, yet bigger than yours. The output should be False.
This is a challenge to write the shortest code, happy code-golfing!

Nice problem specification, but you could add the maximum number of X allowed in the input. :)

There's only one X. The X is "you" and signifies that the room it is in is yours.

Ruby 2.0, 133 characters
A collaboration with @Ventero.  Always a good sign when it starts breaking the syntax highlighter!
This is a recursive flood-fill solution.  Reads from STDIN and outputs to STDOUT:
f=->*a{a.product([~n=$_.to_i,-1,1,n+1]){|p,d|a|=[p]if$_[p+=d]<?.}!=a ?f[*a]:a.size}
gets(p).scan(/ /){$*<<f[$`.size]}
p$*.max<f[~/X/]

See it running on Ideone.

Very nice! I think you can save two more characters by rearranging the splats in f a bit: f=->l{a=[*l];a.product([~n,-1,1,n+1]){|p,d|a|=[p+d]if$_[p+d]<?.};a!=l ?f[a]:l.size}. And correct me if I'm wrong, but it seems like it doesn't actually matter if the first line containing the length is left in $_, which would allow you to shorten the input parsing to gets$e;n=$_.to_i

Ah, even better. :) One more improvement over your last edit: gets(p), as p does nothing and returns nil if called with no argument.

@Ventero great ideas!  For the input line I think we can take it even further and do it all in one assignment: n=gets($e).to_i

@Ventero wow that p trick is a good one!  I guess most of the time it doesn't come up since I'm using gets$e without the brackets.  Thanks again!

Actually, I take back what I said earlier. Using your initial splat arrangement, we can use the fact that product returns the receiver to eliminate l completely: f=->*a{a.product([~n,-1,1,n+1]){|p,d|a|=[p+d]if$_[p+d]<?.}!=a ?f[*a]:a.size} - unfortunately we can't switch the lhs and rhs of != to remove the space, as otherwise both sides point to the unmodified array.

One last improvement: By abusing String#scan and ARGV, finding the largest room can be shortened a bit: $_.scan(/ /){$*<<f[$.size]};p$*.max<f[~/X/]`

@Ventero that scan is tight.  I was trying to think of a way to do it with each_index but it's so verbose!  I love $` though, great idea.

Sorry for bugging you again, but I actually found another improvement... :) By inlining the assignment to n into f with something like [~n=$_.to_i,...], you can then combine the first and third line into gets(p).scan(... for a total of 134 characters.

@Ventero Applied your changes, it's looking good now.  I saved another one by merging the two p+ds into p+=d and p.

GolfScript (85 bytes)
n/(~.*:N:^;{{5%[0.^(:^N]=}/]}%{{{.2$*!!{[\]$-1=.}*}*]}%zip}N*[]*0-:A{.N=A@-,2*+}$0=N=

Online demo
This has three sections:

An initial input transformation which produces a 2D array using 0 to represent a wall, N (the total number of cells) to represent my starting position, and a distinct number between those for each other open space.
n/(~.*:N:^;{{5%[0.^(:^N]=}/]}%

A flood-fill.
{{{.2$*!!{[\]$-1=.}*}*]}%zip}N*

The final counting. This uses a variant on the tip for most common element in an array, adding a tie-breaker which biases against N.
[]*0-:A{.N=A@-,2*+}$0=N=

Thanks for your submission! A CJam translation: qN/(~_*:T:U;{[{i5%[0_U(:UT] =}/]}%{{[{_2$*!!{[\]$W=_}*}*]}%z}T*:+0-:A{_T=A@-,2*+}$0=T=.

Javascript (E6) 155 292
F=(a,n=parseInt(a)+1,x,y)=>[...a].map((t,p,b,e=0,f=p=>b[p]==' '|(b[p]=='X'&&(e=1))&&(b[p]=1,1+f(p+n)+f(p-n)+f(p+1)+f(p-1)))=>(t=f(p))&&e?y=t:t<x?0:x=t)|y>x

Ungolfed base version
F=a=>
{
  var k, max=0, my=0, k=1, t, n = parseInt(a)+1;
  [...a].forEach(
    (e,p,b) =>
    {
       x=0;
       F=p=>
       {
          var r = 1;
          if (b[p] == 'X') x = 1;
          else if (b[p] != ' ') return 0;
          b[p] = k;
          [n,1,-n,-1].forEach(q => r+=F(q+p));
          return r;
       }
       t = F(p);
       if (t) {
          if (x) my = t;
          if (t > max) max = t;
          k++;
          console.log(b.join(''));
       }
    }
  )
  return my >= max
}

Test
Javascript console in firefox
F('6\n......\n.  . .\n.X . .\n.  . .\n.  . .\n......')
1

F('10\n..........\n.   .  . .\n.  .   . .\n.  .   . .\n. ..   . .\n..       .\n..........\n.      X .\n.        .\n..........\n')
0

The second one gives 1 for me too (in Firefox 30.0)

@HackerCow I don't know why, but if you cat & paste from my test code, the white spaces are compressed. Each lines should be 10 chars.

C#, 444 372/(342 thanks HackerCow)bytes
Rather poor score and late to the party, but seems to work. Outputs 1 when you have the single biggest office, 0 when you do not. I've not been very intricate with the golfing yet. Works by building up disjoint sets from the input (first loop), tallying the size of each set (second loop) and then looking to see if my set is the largest (third loop).
Two versions are provided, one is a compilable program tat accepts the input from the command line, the other is just a function that expects a string as input and returns an int as the result (and is just a reworked copy of the first) - it does not need any using clauses or the like, should be able to put it anywhere and it will work.
Program 372bytes:
using System;class P{static void Main(){int s=int.Parse(Console.ReadLine()),e=0,d=s*s,a=d;int[]t=new int[d],r=new int[d];Func<int,int>T=null,k=v=>t[T(v)]=t[v]>0?a:0;T=v=>t[v]!=v?T(t[v]):v;for(;a>0;)foreach(var m in Console.ReadLine()){a--;if(m!=46){t[a]=a;e=m>46?a:e;k(a+s);k(a+1);}}for(a=d;a-->2;)r[T(a)]++;for(;d-->1;)a=d!=T(e)&&r[d]>=r[T(e)]?0:a;Console.WriteLine(a);}}

Function 342bytes:
static int F(string g){var b=g.Split('\n');int s=int.Parse(b[0]),e=0,d=s*s,a=d;int[]t=new int[d],r=new int[d];System.Func<int,int>T=null,k=v=>t[T(v)]=t[v]>0?a:0;T=v=>t[v]!=v?T(t[v]):v;for(;a>0;)foreach(var m in b[a/s]){a--;if(m!=46){t[a]=a;e=m>46?a:e;k(a+s);k(a+1);}}for(a=d;a-->2;)r[T(a)]++;for(;d-->1;)a=d!=T(e)&&r[d]>=r[T(e)]?0:a;return a;

Less golfed:
using System;

class P
{
    static int F(string g)
    {
        var b=g.Split('\n');
        int s=int.Parse(b[0]),e=0,d=s*s,a=d;
        int[]t=new int[d],r=new int[d];
        System.Func<int,int>T=null,k=v=>t[T(v)]=t[v]>0?a:0;
        T=v=>t[v]!=v?T(t[v]):v;

        for(;a>0;)
            foreach(var m in b[a/s])
            {
                a--;
                if(m!=46)
                {
                    t[a]=a;
                    e=m>46?a:e;
                    k(a+s);
                    k(a+1);
                }
            }
        for(a=d;a-->2;)
            r[T(a)]++;
        for(;d-->1;)
            a=d!=T(e)&&r[d]>=r[T(e)]?0:a;
        return a;
    }

    static void Main()
    {
        /* F() test
        var s=Console.ReadLine();
        int i=int.Parse(s);
        for(;i-->0;)
        {
            s+="\n"+Console.ReadLine();
        }
        Console.WriteLine(F(s));*/

        int s=int.Parse(Console.ReadLine()),e=0,d=s*s,a=d;
        int[]t=new int[d],r=new int[d];
        Func<int,int>T=null,k=v=>t[T(v)]=t[v]>0?a:0;
        T=v=>t[v]!=v?T(t[v]):v;

        for(;a>0;)
            foreach(var m in Console.ReadLine())
            {
                a--;
                if(m!=46)
                {
                    t[a]=a;
                    e=m>46?a:e;
                    k(a+s);
                    k(a+1);
                }
            }
        for(a=d;a-->2;)
            r[T(a)]++;
        for(;d-->1;)
            a=d!=T(e)&&r[d]>=r[T(e)]?0:a;
        Console.WriteLine(a);
    }
}

The way I understood it you don't have to actually write a working program, a function is sufficient. So if you drop all the stuff before the Main function and replace the function with, say int f(string s) you could use s.Split('\n')[0] instead of Console.ReadLine() and return 1 or 0. This should save you a lot of code

@HackerCow thanks, I completely missed that clause! I'll put a function version in my next edit.

CJam, 106 bytes
A different approach to flood fill. Although, makes it longer ...
liqN-'Xs0aer\_:L*{_A=' ={[AAL-A(]1$f=$:D1=Sc<{D2<(aer}*D0=_' ={T):T}@?A\t}*}fAT),\f{\a/,}_$W%_2<~>@@0=#0=&

Try it here

Thanks for your submission. But your program throws an exception with this input: http://pastebin.com/v989KhWq

@user23013 fixed.

Try these: http://pastebin.com/WyRESLWE

Python 2 - 258 bytes
r=range;h=input();m="".join(raw_input()for x in r(h))
w=len(m)/h;n=0;f=[x!='.'for x in m]
for i in r(w*h):
 if f[i]:
    a=[i];M=s=0
    while a:
     i=a.pop();s+=1;M|=m[i]=='X';f[i]=0
     for j in(i-1,i+1,i-w,i+w):a+=[[],[j]][f[j]]
    n=max(s,n)
    if M:A=s
print A==n

uses stdin for input
Note: first if is indented by a single space, other indented lines are either using a single tab char or a tab and a space.

J : 150 121 bytes
(({~[:($<@#:I.@,)p=1:)=([:({.@#~(=>./))/@|:@}.({.,#)/.~@,))(>./**@{.)@(((,|."1)0,.0 _1 1)&|.)^:_[(*i.@:$)2>p=:' X'i.];._2

Edit: id and comp were ridiculously complicated and slow.
Now it works shifting the map 4 times, instead of scanning it with a 3x3 window using cut (;.).
Takes as argument the blueprint as string. Explained below:
    s =: 0 :0
..........
.   .  . .
.  .   . .
.  .   . .
. ..   . .
..       .
..........
.      X .
.        .
..........
)
p=:' X' i. ];._2 s                NB. 0 where space, 1 where X, 2 where wall
id=:*i.@:$2>p                     NB. Give indices (>0) to each space
comp =: (>./ * *@{.)@shift^:_@id  NB. 4 connected neighbor using shift
  shift =: ((,|."1)0,.0 _1 1)&|.  NB. generate 4 shifts
size=:|:}.({.,#)/.~ , comp        NB. compute sizes of all components
NB. (consider that wall is always the first, so ditch the wall surface with }.)
NB. is the component where X is the one with the maximal size?
i=: $<@#:I.@,                     NB. find index where argument is 1
(comp {~ i p=1:) = {.((=>./)@{: # {.) size

NB. golfed:
(({~[:($<@#:I.@,)p=1:)=([:({.@#~(=>./))/@|:@}.({.,#)/.~@,))(>./**@{.)@(((,|."1)0,.0 _1 1)&|.)^:_[(*i.@:$)2>p=:' X'i.];._2 s
0

Python 2 - 378 bytes
Wow. I'm out of practice.
def t(l,x,y,m,c=' '):
 if l[y][x]==c:l[y][x]=m;l=t(l,x-1,y,m);l=t(l,x+1,y,m);l=t(l,x,y-1,m);l=t(l,x,y+1,m)
 return l
def f(s):
 l=s.split('\n');r=range(int(l.pop(0)));l=map(list,l);n=1
 for y in r:
    for x in r:l=t(l,x,y,*'0X')
 for y in r:
  for x in r:
    if l[y][x]==' ':l=t(l,x,y,`n`);n+=1
 u=sum(l,[]).count;o=sorted(map(u,map(str,range(n))));return n<2or u('0')==o[-1]!=o[-2]

This is a function answer, but it pollutes the global namespace. If this is unacceptable, it can be fixed at the cost of 1 byte:

Add a space to the beginning of line 1 (+1)
Replace the space at the beginning of lines 2 and 3 with a tab character (+0)
Move line 4 to the beginning (+0)

I had a whole long explanation written out, but apparently it didn't save properly and I'm not doing that again l m a o