text:
Hello world! with limited character repetition
In a language of your choice, write a program that exactly outputs the characters Hello world! followed by a newline. The code:

should not use any character more than twice (alphanumeric, symbol, whitespace...anything)
should not use any external resources
should not use any user input
should not output anything else

An example of a valid python program:
print("He%so world!"%(2*'l'))

An example of an invalid python program (the character 'r' is used three times):
print("Hel"+chr(108)+'o world!')

Winner is whoever has the most votes after 14 days.
EDIT:  A winner has been chosen!  Thanks all for your work on this question!

Is it allowed to use a letter more than twice in different case? E.g. "RRrr"

@Boann since I did not specify in the original question, it is allowed (since they are technically different characters).

What about the repeated letter o in the "valid" python example. There also these:- " ' ( )

@AdamSpeight what do you mean?  The letter is only used twice, as per the specs.

@josh The first condition need to be rewritten to be more clearer.
should not repeat a character more than twice. Eg alphanumeric, symbol, whitespace...anything

@AdamSpeight ... which is literally the same.

@VisioN It isn't literally the same. The original makes it more prominent that it reads as no repetition. Eg only one use of a character is permitted (which it is what it's asking). Whereas in my version the condition is much easier to read, as it doesn't break the condition into two halves.
comments doesn't preserve the line breaks which makes it impossible to display an example.

@AdamSpeight: Then make an edit if you feel that strongly about it.

It seems, it con not be done using java?

@Prizoff I believe so.

I think you mean a character should not appear more than twice, that is, it should not be repeated more than once.

I guess [tag:brainfuck] is out of the question...

VB.net (impossible?) Console.WriteLine() As just to output something uses o x 2 e x 3 ( x 1 ) x 1 l x 1 r x 1 Edit
Also consider that the minimal about of required ceremony is Module z Sub Main End Sub End Module Also VB doesn't have C#'s escapes sequences \x108 .

No, it's not doable in Java.  I've been trying to do it for fun.  Impossible to do it with less than two s characters.  At best, you have to have a class word and a static word, which is three.

Do include <file>s count?  I can't do it in C++ unless they don't.

includes do count.

You know that you are dealing with ascii values too much when you see any number (in this case, the vote count of 32) and immediately translate into the appropriate character (Space). I guess Befunge just does this to people.

in your valid example 'l' is used twice!

@BlueFlame reread the requirements especially the first.

@BlueFlame It is ok to use a character more than once. You can use 2 of the same characters.

how the first python program be valid if it uses 2 os, 2 (, 2), 2 " (quote), 2' (apostrophe), the spec only says that "should not use any character more than twice (alphanumeric, symbol, whitespace...anything)", not "should not use any character more than twice (alphanumeric) repetitively"

Should this question be protected? I've seen at least 2 answers that weren't answers.

In-browser javascript console counter: function t(s){return [].reduce.call(s,function(n,c){n[c]=1+(n[c]|0);return n},{})} - usage t('golfcode'). Escape backslashes as \ to avoid getting literals.

impossible in D unfortunately as to output anything you need to import std.stdio; (3*t)

The valid python also has two r!!

@JeffGohlke Note that you can get a bit farther by substituting an s by \u0073. You can only substitute one because then you'll run out of 0s, so you still can't have a working Java program (you also need 3 ts and is).

@Mehdi Read the rules again...

The rules are ambiguous. Your example print("He%so world!"%(2*'l')) uses 'l' and o twice. It also contains multiple r"'() characters in the source, if that matters.

Right. The rules say "should not use any character more than twice (alphanumeric, symbol, whitespace...anything)", so you can have TWO of each character.

@Lưu Vĩnh Phúc — What are you trying to say ?

@NicolasBarbulesco misread. I thought it was non repetition, only one character allowed

Ruby (1.9+)
Since this is a popularity contest let's try to not use ANY of the characters from 'Hello world!' while still using other characters only a maximum of two times:
puts("S\107VsbG8gV29ybGQhCg".unpack(?m))

It's 40 chars btw.
Bash
And this one uses unicode magic.
Notes:

While the orignal characters appear elsewhere (unlike the ruby example), the printed string contains only non-ascii characters.
Two from the three spaces are actually tabs, so there are no utf-8 characters that appear more than 2 times
As binary some of the octets do appear more than 2 times, hopefully that's not against the rules. I'm trying to resolve them though.

Code:
echo ' ¡'|iconv -t  asCIi//TRANSLIT

For those who don't have a proper font installed it looks like this:

Here is the hexdump:
00000000  65 63 68 6f 20 27 f0 9d  93 97 f0 9d 90 9e f0 9d  |echo '..........|
00000010  91 99 f0 9d 92 8d f0 9d  93 b8 e2 80 8a f0 9d 93  |................|
00000020  a6 f0 9d 97 88 f0 9d 96  97 f0 9d 96 91 f0 9d 98  |................|
00000030  a5 c2 a1 27 7c 69 63 6f  6e 76 09 2d 74 09 61 73  |...'|iconv.-t.as|
00000040  43 49 69 2f 2f 54 52 41  4e 53 4c 49 54 0a        |CIi//TRANSLIT.|
0000004e

You have to run it on a machine where the default charset is utf-8. I tried on an OSX10.8 using iTerm2 with the following environment:

PHP 5.4
This uses zLib: (unfortunately it does uses the characters e and o)
<?=gzuncompress('x▒▒H▒▒▒W(▒/▒IQ▒!qh');

Hexdump:
00000000  3c 3f 3d 67 7a 75 6e 63  6f 6d 70 72 65 73 73 28  |<?=gzuncompress(|
00000010  27 78 9c f3 48 cd c9 c9  57 28 cf 2f ca 49 51 e4  |'x..H...W(./.IQ.|
00000020  02 00 21 71 04 68 27 29  3b                       |..!q.h');|
00000029

+1
Here is the ruby 2.0 code I used to test for duplicates:
d=ARGF.read
p [d.split(//),d.unpack('C*')].map{|x|x.inject(Hash.new(0)){|i,s|i[s]+=1;i}.select{|k,v|v>2}}

While I always appreciate Unicode cleverness, your bash attempt doesn't seem to satisfy the question's specification. "write a program that exactly outputs the characters Hello world! followed by a newline"

@FireFly: it does satisfy it. iconv with the target encoding ascii//translit will transliterate the unicode characters to basic ascii. And of course echo will add the newline, so this one fits the spec (if we don't consider the similarity of the octets)

On my system I get Hello World? instead of Hello World!

@SztupY oh, you're right, my bad. Very clever, I like it!

@marinus this unfortunately depends on the iconv version used. I'll clarify the environment and put up a screenshot.

How many bonus points would you get if your duplicate-checker also conformed to the repeating spec? :-)

@corsiKa: I've been thinking about this for 15 minutes, but unfortunately I need at least 4 .-s (and also need to decrease c,h and r from 3): ARGF.chars.sort.chunk(&:ord).each{|y|p y}

@SztupY I'm not a ruby guy, but what if instead of sorting and chunking, you just counted and spit out the counts? That might cut down on the number of .'s, perhaps replacing them with a () pair if you use a closure? But again, I'm not a ruby guy.

Your first hexdump has the character 9d ten times.

@MrLister '\x9D` is an octet that is part of a single Unicode character. The question did specify repetition of characters, not bytes, so I'd consider this legal. Anyway, he could encode it in UTF-32, in which case going by (32-bit) characters would make it satisfy the rules.

Congrats on the win, @SztupY!

The Bash solution has pretty Unicode  ! :-) However, it does not give the exact string wanted by the question. One can correct this with a ``.

@NicolasBarbulesco: oh, you are thi first one to discover that I have used an uppercase W :)

You have to use more expressive languages.
Chinese,  6  4   3 chars
喂世!

Running google translate on this produces  Hello world!
(thanks @sreservoir and @Quincunx for the update)

+1 for rule bending... "In a language of your choice..."

Love it. But how exactly is that a program?

Actually you can look at it as a program in a google translate language - for Chinese as its sub-language :)

+1. Nice idea. 世界 = Shì jiè = World. 你好 = nǐ hǎo = Hello. "World, Hello!" translates to "Hello World!". It can be golfed down some more: 你好世!

@Tomas Native speaker? Whom are you talking about? I'm no native speaker; the only part of your answer I understood was 你好 (and the fact that "World, Hello!" means "Hello World!"). I used google translate to figure out the other part. My "improvement" came from fiddling around on google translate.

@Quincunx OK, sorry! I supposed no one else would understand Chinese. You are a real hacker. :) I will delete the irrelevant comment.

can be golfed down further to 喂世! at the expense of ... well, nothing more is really being expended.

@sreservoir wow, thanks! Seems to be more exciting than debugging a classical programming language!! :-)

Haha, 喂世! is giving me "Feed the world!" as the first option.

HQ9+, 1 char
H

keeping it simple :)

HQ9+ outputs a comma though ;)

oh sh.. you're right!

I'd still keep your answer out...it is a popularity contest after all, rules are for the wind!

For any challenge like this, HQ9+ should be outlawed just because it's so obvious to begin with.

@Josh This is one of the rare events where I miss the downvote button on comments. If we throw away rules there is nothing left to justify the contest at all.

@Howard I feel dirty. I upvoted yours and Josh's comment

This is what I was about to post. Maybe I should post an answer in H9+, HQ9++, CHIQRSX9+, etc..

All print Hello World questions are actually who can submit a HQ9+ answer faster questions.

What does this output ?

Vim command (18 keystrokes)
iHeEsc3alEscio WorRightd!Enter
Doesn't repeat any keystroke more than twice.
It kinda violates the "user input" rule since it's still the user that needs to input that sequence, but I suppose if you store it as a macro or an nnoremap beforehand it would count, since you're just running it without explicitly doing any input to make it happen.
It also requires nocompatible to be set, which may count as using external resources, so I have provided another variation below:

Vim command (21 keystrokes)
iHeEsc3alEscio WorCtrl+[$ad!Enter
This variation doesn't require nocompatible to be set, although it does work around using Esc three times by using Ctrl+[ in its place.

That's awesome!

you have an 'e' and 3 'E'; 3 'i'

If you're talking about the characters in Right, Esc, and Enter, they're not literally those characters. Vim deals in keystrokes, which I am deeming equivalent to characters for the purposes of this contest (and the "don't repeat more than twice" rule). I only use the i keystroke twice, and the <Right> keystroke once. As for E, I never use it at all - but I do use <Esc> twice and <Enter> once.

Now I'm disappointed that Emacs doesn't have a M-x hello-world command...

Even if it did, that's three ls.

You should note that you have to :set nocompatible.

Amazing, but myself find using Right not very vim-y.

@jazzpi: Wait, really? I didn't even notice.

What part requires set nocompatible? I found it in my .vimrc, so I think I didn't even notice it wasn't default settings.

@JoeZ.: The set nocompatible makes VIM not act like vi, in that vi didn't actually support movement with the arrow keys but would print A, B, C and D instead of applying the movement.

I see. If you wanted to do it without nocompatible, you'd have to replace Right with something like <C-[>$a, which increases the keystroke count to 21.

C, 192 chars
#
#
/*$$@``*/ATION_[]={9.};main(BBCDDEEFFGGHJJKKLLMMPPQQRRSSUUVVWWXXYYZZabbdefgghhjjkkmpqqsstuuvvwxyyzz) {printf("He%clo \
world!%c\
",2^7&!8.&~1|~-1?4|5?0x6C:48:6<3>2>=3<++ATION_[0],'@'^79-5);}

Since this isn't golf, I decided to have some fun and try to use every character exactly twice (while putting as few as possible in a comment, because that's boring).  I realise that I didn't do terribly well, since my code contains a ton of boring "dead" code too (not in the literal sense, but in the sense of placeholder characters just used in order to fullfil the requirement).  Anyway, this was surprisingly hard (but fun) with the two-character limitation, so unfortunately I couldn't come up with anything more interesting.  It did give me an idea for a new problem though...
(Updated per @ugoren's comment.)

Creatively impressive.  I like it.

The slash \\ ending lines three and four make it a line continuation, not newline.  And line four is terminated by a EOF, making it legal.

I think you can easily uncomment . by using it for fractions. Also you can declare an array and use [].

@ugoren good call about .; I only thought about using it for struct access. As for array declarations, I'm out of ,s due to the printf call, and I'm also out of ;s, so I'm not sure how I could declare one. Duh, I could replace ATION_...

Piet-- No characters whatsoever!

I would consider the codels as "characters".

@PaŭloEbermann What would you consider to be a unique codel? EG different shapes? colors? sizes? some combination thereof?

@ValekHalfHeart the definition of a unique codel is given in the specs of the language: it s a block of codel that could be simplified as a single colored pixel.

@plannapus In that case I don't this challenge is technically possible in Piet. I may come up with something creative though.

@ValekHalfHeart oh it wasn t a criticism of this answer: i love it! This challenge was not a codegolf anyway.

Perl, 29 characters
This answer includes x-rated clogs!
say"07-8*d<#B+>!"^xRATEDkL0GZ

Perl, 23 characters
Shorter, but no porno shoes. :-( Same basic idea though...
say'0@@lo World!'^"x%,"

Perl, 20 characters
Boring...
say"Hello Wor\x6Cd!"

Um....kinky?  +1 :)

Powershell, 20
"He$('l'*2)o world!"

Sclipting, 11 characters
丟낆녬닆묬긅덯댦롤긐뤊

I saw this beautiful HelloWorld program on esolang's Hello World program list.

Whoa! Congratulations, you are the first person ever to post anything about any of my esolangs outside of esolangs.org :) (or at least the first I found out about)

Scala: 34 29 characters
I'm proud of myself for this one:
printf("He%c%co world!\n",108,108)

Had a really hard time overcoming duplicate 'l's, 'r's, quotation marks and brackets. Then I discovered the old Java printf function, which will happily convert numbers to letters when given the %c format specifier.
Update
MrWonderful did a wonderful thing by pointing out that a whole bunch of characters can be saved by using up my second 'l' manually in the string!
printf("Hel%co world!\n",108)

@KCaloux, Since you are allowed up to 2 'l's, wouldn't printf("Hel%co world\n",108) at 28 be even better?

@MrWonderful I think you're absolutely correct! (Also I just realized that I forgot to include the '!')

From what I understand, this isn't a valid entry, though a good attempt at it. printf contains a r as does world. Same goes for the letter o which is used more than once. This is based on my interpretation of the following statement from the OP "An example of an invalid python program (the character 'r' is used three times): print("Hel"+chr(108)+'o world!')"

@JAnderton I had a ruby program parse out my script to make sure there were no characters included more than twice. Read it again. There are 2 rs, not 3. One in "printf" and one in "world". The reason the python one is invalid is because it includes chr

Python 3 [38 bytes]
exec('import '+chr(95)*2+"h\x65llo__")

I wouldn't consider import __hello__ as an external resource.

Perl: 34 characters
$_="He12o wor3d!
";s{\d}{l}g;print

Sample run:
bash-4.1# perl -e '$_="He12o wor3d!
> ";s{\d}{l}g;print'
Hello world!

(Not a big deal. Posted just to use at least once in my life s/// with those fancy delimiters.)

PHP, 33 chars
I just love how much PHP is forgiving and understanding!
<?=Hel.str_rot13("yb jbe").'ld!';

Before it was deleted (or if it's still there, I'm totally blind), I saw a comment saying "No brainf*ck? :D". Well, it is pretty much impossible to write a solution in BrainF*ck, as you know. But I managed to code this, just for the lulz.
++++++++++[>++++>+++++>++++++>+++++++>++++++++++>+++++++++++>+++++++++<<<<<<<-]
>>>.+++.--.>++.>+.+++++++.<<<<++++++.>>>>>+++++.+.--.>+++++.<.---.+++++.<<<<-.+
+.<------.------.>>>>>+++++.<----------.<<<<--.>>>>++++++++.--------.+++.
<<<<++.+++++++.+++++.-------.>>>>+++++++.--------.<<<<------.++++++.>++++++++.

If you don't have a BF interpreter, the code above just prints the PHP one :P

I didn't know even a code like this is valid! Php tag isn't closed and string Hel isn't surrounded by quotes. Also I've never heard about str_rot13 before.

@AycanYaşıt the closing php tag is not required on EOF, and if you put a string without quotes it assumes it is an undeclared constant with the same content as its name and gives a warning

You have two ls...

@Manishearth Ooh, you should see the comment thread on the question.

I commented regarding Brainfuck keeping in mind that it will be completely impossible not to use same characters more than twice :)

You can avoid the warning (and save the first .) by putting the Hel before the <?=.

@PaŭloEbermann Hel<?=str_rot13("yb jbe")?>ld!

@VisioN I know, I wrote that just for the lulz, as I stated before! :)

@PaŭloEbermann I would say that using that is like cheating, since it's not pure PHP anymore.

HTML Fiddle - 21 characters
Hello World!

Does that include the trailing newline?

Doh...missed that requirement!  I'll add a  in there.

I'm not quite sure that the
 tag actually outputs a \n character.

@netinept :It asked for a newline, not a \n so I'd say
 counts

But the character r is repeated in the solution. Did I misinterpret the requirements?

"l" and "o" too, but each character can be used twice at most.

Ruby: 27 characters
puts [:Hel,'o wor',"d!"]*?l

Sample run:
bash-4.1# ruby <<ENDOFSCRIPT
> puts [:Hel,'o wor',"d!"]*?l
> ENDOFSCRIPT
Hello world!

Ruby: 25 characters
(Based on Vache's comment.)
puts 'He'+?l*2+"o world!"

Ruby: 23 characters
(Copy of Danko Durbić's Powershell answer.)
puts"He#{?l*2}o world!"

puts 'He'+'l'*2+'o world!' is one character shorter!

But has 6 “'”'s…

haha I was so focused on letter characters that I never noticed that. never mind!

@Vache, your comment is actually good. Thank you for it.

Remove the space after puts and make it 23. -- puts"He#{?l*2}o world!"

Also puts can be replaced by p. So 20 chars. -- p"He#{?l*2}o world!"

@SampritiPanda, p includes quotes in the output. I prefer to keep strictly with the required output format. But you are right, the space is not needed. Thank you.

C - 43 Characters
main(){printf("Hel%co World!%c",'k'+1,10);}

Output
Hello World!

Character Counts
' ' Count: 1    '!' Count: 1    '"' Count: 2    '%' Count: 2    ''' Count: 2
'(' Count: 2    ')' Count: 2    '+' Count: 1    ',' Count: 2    '0' Count: 1
'1' Count: 2    ';' Count: 1    'H' Count: 1    'W' Count: 1    'a' Count: 1
'c' Count: 2    'd' Count: 1    'e' Count: 1    'f' Count: 1    'i' Count: 2
'k' Count: 1    'l' Count: 2    'm' Count: 1    'n' Count: 2    'o' Count: 2
'p' Count: 1    'r' Count: 2    't' Count: 1    '{' Count: 1    '}' Count: 1

Don't you need main etc?

@FireFly I guess so!  It did say to write a program.

That's C but not C++.  C++ does not have implicit int (and you can't spare another i).

@BenVoigt Okie dokie!

JavaScript, 66 characters
alert('Hel'+window.atob("\x62G8gd29ybGQhCg=="));//rH+in.\x689yQhC;

Inspired by FireFly, every character used by this code is used exactly twice.

I think you are allowed to use some characters just once, and you can drop the comment.

@JanDvorak - well, sure he could have done it that way - but I think this solution is deserving of an upvote for the sheer bloodymindedness of using each and every character exactly twice. :-)

+1, but it's easy to use each character exactly twice if you just add gibberish as a comment.

JavaScript [37 bytes]
alert(atob("SGVsbG8g")+'wor\x6cd!\n')

Too primitive isn't it?

Where’s the newline?

@ChristopherCreutzig Sorry, forgot it. Now it is in place.

nginx.conf
return  200 "He&#x6clo wo&#x72ld!\n";

In action:
% curl -6 http://localhost/ | lynx -dump -stdin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    21  100    21    0     0  20958      0 --:--:-- --:--:-- --:--:-- 21000

   Hello world!

%

There are 4 spaces in this solution...

@Josh, actually, there are 5.  But couldn't you consider that two of the first four are tabs, and then the last one is a non-breakable space? :-)

That works for me!

@Josh, actually, now that we're using HTML, no more need for set.  This only has 3 spaces now, any one of which could be a tab!

Very nicely done.

Uses 3×'r' though

@JoelPurra, nice catch, fixed. :-)

Emacs Command (15 keystrokes)
He<Ctrl-3>l<Left>o wor<End>d!<Enter>

If that vim answers is legal then this must be too :)
Joking aside, macro it can become too :)
More nonsense aside, I can probably squeeze some more, but this seems to be good enough for the time being (since it beats vim).
P.S., please ignore all my nonsense (I (rarely, but)use vim too!).

I still think vim > emacs.

Befunge 98
a"!dlrow ol":'e'Hck,@

Here is a version where every character appears twice.
bka!e:dw"H@!dlrow  ol":'e'Hbk,a,@

Leaves a bunch of junk on the stack.
As a bonus, every single character has something done with it by the IP.

Malbolge
(=<`#9]~6ZY32Vw/.R,+Op(L,+k#Gh&}Cdz@aw=;zyKw%ut4Uqp0/mlejihtfrHcbaC2^W\>Z,XW)UTSL53\HGFjW

Unfortunately, this seems to print Hello, world. instead of Hello world!\n :(  Try it online! Impressive, but invalid.

Actually I don't like cheating :P
Python
print("!dlrow os%eH"[::-1]%('l'*2))

You should specify that it's for python2. In python3 the you get the reversed string as output and then a TypeError.

For use in Py3K argument of print must by enclosed in parenthesises. print("!dlrow os%eH"[::-1]%('l'*2)) work in both (Python2 and Py3K) versions.

GolfScript
'He

o world!'n/"l"*

Substitutes two newlines (fortunately the third one, needed for the substitution, is provided by the built-in n), using both types of string literal to avoid quadruplicate copies of a quote mark. Since l is the only character which occurs more than twice in the original string, it's not too hard.

You forgot the "!".

@Howard, missed it. Oops.

The letter o is repeated also

@AdamSpeight: There is only twice the letter o. The rules say that it's not allowed to have a character more than twice.

Hmm.
In C, given these rules, we can only have one #define (because of i and n) and at most two function calls OR definitions (( and )).
I presume there's pretty much only one way to do it (though I'm probably wrong):
main(){puts("Hello w\x6fr\154d!");}

You still need to output the trailing newline.  Doing this challenge in C is difficult...

@Josh I just have to use puts() instead of printf().

But what's wrong with o in world?

@VisioN In an old draft of the same code (before I realized how hard it actually was to write such a program) I used another 'o' elsewhere. But this isn't [tag:code-golf], so I guess it doesn't have to be fixed.

In fact, I'm not sure why every answer is displaying a character count.

XQuery, 19 chars
"Hello World!"

BASH
printf 'Hel\x6co world!\n'

Cred @manatwork
echo $'Hel\x6c\x6f world!'

The first one has 3 “e”'s and 3 “o”'s.

@manatwork: Gag; thanx ;)

In Bash you may skip -e by using the special $'…' syntax: echo $'Hel\x6c\x6f world!'.

C - 46 Characters

main(){printf("He%clo wor%cd!\x0d",'l',108);}

Prints out:

Hello world!

If you're aiming for golf, main(){printf("He%clo world!%c",108,10);} should work, and saves you a few chars.

@FireFly you're right, you'd save me 3 characters.  Your suggestion works perfectly, too.

PHP
32 Chars
Note how I am not using a character more than twice, since l != L
He<?=strtolower("LLO WOR");?>ld!

Also note that, despite of Stack Overflow deleting it in the representation, there's a line break after the !.

You are using three spaces, but I guess this can be fixed removing the ones near the PHP tags! :P

That was fast, although I realized before of reading your comment (from another answer actually)

Isn't the output "H" supposed to be uppercase?

Completely true, missed that also ):

AWK,34
BEGIN{printf"Hel%co world!\n",108}

GolfScript, 21 characters
'He'[108]+"lo world!"

108 is the ASCII code for l.
First, I push He on the stack. Then, He gets popped and becomes Hel. Then I push lo world! on the stack. Now there are two elements on the stack. Because at the end of a GolfScript program, everything of the stack is outputted, this program outputs:

Hello world!

followed by a newline, because Golfscript always outputs a newline.

nginx.conf
set $i l;
return 202 "Hel${i}o world!\n";

In action:
opti# curl -6v "http://localhost/"
* About to connect() to localhost port 80 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 202 Accepted
< Server: nginx/1.4.1
< Date: Fri, 17 Jan 2014 18:02:08 GMT
< Content-Type: application/octet-stream
< Content-Length: 13
< Connection: keep-alive
<
Hello world!
* Connection #0 to host localhost left intact
* Closing connection #0

Unfortunately your code has three e's and three l's!

One of the duplicate l's can be removed easily. e is harder, unless nginx is case-insensitive

Don't forget the spaces!

And 3×'r', as well

HTML — 17 characters
Hello world!

In action:
%echo -n "Hello world!" | wc
       0       2      17
%echo -n "Hello world!" | lynx -dump -stdin

   Hello world!

%

Fugue
From the esolang wiki:

And you can listen to the source code.

I'd say this is invalid. I can see more than 4 middle c's in the right hand.

Not to mention the string of four consecutive G's in the 9th measure.

Did you write this, or only render it? Given that you link to the esolang archive's MIDI.

-1 for plagiarism. This is from esolang wiki. You do not cite it. Edit: reverted, now the esolang wiki is cited.

-1 for using the same note more than 2 times.

Clojure (35)
(printf "He%c%co world!\n",108,108)
The whitespace almost got me, but Clojure allows the use of commas to separate parameters.

You could always have used different types of whitespace--space, newline, tab, vertical tab, form feed.  I'm not completely sure of Clojure's grammar off the top of my head, but the first tree ones would likely work at least.

But it was interesting to try out this use of commas in Clojure. I thought I'd read somewhere that they could be used to substitute for whitespace but hadn't messed with it.

As MrWonderful pointed out for my Scala version, you're only using a single 'l'. You could save a few characters by using your second, for (printf "Hel%co world!\n",108)

Perl, 28 chars
printf"He%so world!\n",'l'x2

Rules tested with:
perl -e '$"="\n";@a=split//,<>;print"@a";' | sort | uniq -c | sort

C (32 characters)
main(){puts("He\x6clo world!");}

Plain TeX - 18 chars
He^^,lo world!\bye

Remark: TeX terminates the paragraph before shipping it, so the "newline" is actually included.

Taking it directly from the instructions on this page:
curl -sL bit.do/gBfx|perl -E'@Q=map{m%OUtPUTS The chARAC.ERS\N*?>([^<]+)%i?$1:()}<>;say$Q[1]'

or, if you wanna be strict with the white-spaces:
PERL
`curl -sL v.gd/92XIMS`=~m%ThE\WChAracTERS.*?>\K[^<]+%i;say$&

or
`curl -sL v.gd/qmwAMh`=~m%outpUtS\WTHE\WChAracTERS.*?>([^<]+)%i;say$1

Advantage: will work for every sentence, but please don't change wording of the question :)
Rules: we can consider this question being an "internal" resource. Without this question, no one would solve it. Should it be me or the program reading it? :)
Backstage story: I almost teared out all my hair trying to debug this! :)
First solution

using wget -O- leads to 3x -
sed needed too many /
so I need curl and perl, but all perl loops like until, while contain 3rd l!
I needed to replace the loop, this is quite complicated but

it seems $1 only works after positive (=~) not negative (!~) match
I couldn't use !(..) - too many parentheses :x
neither I could use || (I need a pipe!) or or (perl, curl ...)

Second solution

I reread the rules. White-spaces shouldn't be repeated either - oh my!
At least could recycle the do{}while idea. Better said, it was forced, the map solution could not be used for using () 2 times, 3rd needed to call open since no more whitespaces are left.
Find proper url shortener was a story, using goo.gl, bit.ly, is.gd or ow.ly was obviously impossible for the first solution, as was bit.do and dft.ba for the second. Then, url-shorten the URL until you get something you can use, especially with bit.ly and v.gd. Why on earth they use so much lowercase characters?

The regex could be shortened, but I like the instructions to be as long as possible :-)
These rules are damn crazy :)

PERL v5.10 say feature has to be enabled, e.g. by running PERL -E option

For the first one, you have a backslash left, right? You could do two tabs and one escaped newline for the spaces in the shell part.

@FireFly what a neat idea :) I don't now why I limited myself to spaces. I guess because I like one-liners that can just be copy-pasted :)

Keg, 13 bytes
The winner was chosen, but I still want to do it. :) (Astonishingly it is shorter than HTML!)
Hel:o world\!

This is a popularity contest, but the program is very easy to understand despite of the conciseness.
Explanation
Hel          #Push "Hel" onto the stack
   :         #Duplicate the top of the stack (l)
    o world  #Push "o world" onto the stack
           \!#Escape ! and push it onto the stack(since it is an instruction)

LINQPad, C# Expression - 22 chars
"Hello w\x6fr\x006cd!"

PHP, 30 characters
Highly inspired by Vereos's answer.
<?=Hello.' wor'.chr(108),"d!";

HTML - (16 Chars):
Hello Wor&#108d!

Proper HTML would be to put a ; after &#108 but it still compiles fine. :)

HTML... compiles fine?

@MrLister Yes, it compiles fine. It is a good practice to put a ; at the end of it, but it still compiles.

Oh wait, now I get it. You're creating .chm files! Sorry I didn't get that the first time.

@MrLister, Uh... No. I'm making .htm files.

Let's just agree to disagree; that would be easier.

@MrLister I don't follow...

That's alright, I don't follow either.

C
q=7103816;
main(){printf("%slo world!%c",&q,2+8);}

Works on little-endian platforms, where 7103816 is encoded the same as Hel\0.

Missing \n at the end.

Thanks @mcleod_ideafix. I was going to simply add \n, but I'm out of ns. Fortunately, I had % and , to spare.

C, 41
main(){printf("He%clo world!%c",108,10);}

You're using the character n three times.  (main, printf, \n)

Good work replacing the \n but your score was wrong. I updated the 33 to 41.

Lua - 22 characters
print"Hel\108o World!"

Simple enough, example output
lua -e 'print"Hel\108o World!"'
Hello World!

Javascript, 19ch
> 'Hello Wor\154d!\n'
Character count:
> "'Hello Wor\154d!\n'".length -> 15 //cough, cheating
> "'Hello Wor\\154d!\\n'".length -> 19
With your choice of return, alert(), or nothing? Man, javascript has too many contexts.
Slightly more interesting: ["He",,'o World\n'].join('l')

Your correct variant has 4 times \ I think ;)

Яussian
Хелло мир!
A mix of transliteration and proper language :) Google translate will turn it into proper "Hello world!"

I guess this wouldn't even be accepted in a code-trolling question, lol. Nice interpretation of the In a language of your choice sentence, but here's Programming Puzzles and Code Golf site!

R
Not gonna win anything, but I didn't see R yet...
'He\154\154o, World!'
'Hello, Wor\154d!'

TI-BASIC, 33 bytes on-calculator
"l→Str1:Disp "He..o World!
Str1:Output(2,3,Ans+Ans

Since TI-BASIC uses tokens instead of characters, I limited myself by token. Make sure the screen is cleared before running the program. Note that l and o are two-byte tokens, but w is a sequence variable and d, e, and r are statistics variables, which are all one-byte tokens. This program first Displays the string without the first two l's, and then uses a different command to paste in the other two. Also note that TI-BASIC has no equivalent to a newline, but when the program ends the cursor does move down to allow further input to the calculator.

Oh wait, I used 4 commas. I will have to redo this

Wait, this doesn't work at all because Disp overwrites Ans.

Fixed. I now made use of both Str1 and Ans.

Hexish
0B

According to the documentation that prints hello world.  We need a capital H, a !, and a newline.  Close, but no cigar!

@Josh Closer than you think... it actually prints Hello World!

Ehm, the Esolang page says that this language falls under the category "Unimplemented". Is that allowed? I mean, are unimplemented languages allowed?

In that case, I will now invent a new language SECODEGOLF where every program consists of a single decimal number, and the output is the solution to the corresponding CodeGolf question. For instance, the program 18721 would print "Hello World!" and a newline.

@MrLister Arguably SECODEGOLF is mostly implemented by this website. (Part of the implementation is crowd-sourced.) And most languages' specifications are only mostly implemented. :)

Haskell, 27
main=print"Hello Wor\108d!"
Twice-check:
import Data.List
main=getContents>>=print.all((<3).length).group.sort

q/kdb [16 chars]
"hel\154o world"

itym -1"Hel\154o world!";

Node.js - 54 Unicode characters
eval([]+Buffer('consolť.ŬůgĨĢHťŬɬů wɯrɬd!Ģĩ',"ascii"))

console.log outputs a given string and a line shift, unfortunately that initially leaves me with way too many ls and os, so it took some work.
The code creates a buffer from a string and is told to use ascii encoding, this effectively takes all character values mod 256 and stores them in the buffer, the buffer is then added to an empty array, which cause both buffer and array to be converted to string before the addition, an empty array converts to an empty string, and the buffer is implicitly converted using UTF-8 encoding. The result is evaled to produce the desired result.

PHP
I am amazed at how many people give invalid answers without mentioning they are.
My attempt, only reusing o" characters twice.
<?Php EchO "Hello wor\154d!";
Edit: fixed thanks to @FireFly: i understood to use each character once. This is no challenge anymore.

Wouldn't changing the \X6C into l make it completely valid? I only see one other l in there.

Active Server Pages (Classic ASP):
Hel<%REspOnsE.wRite Chr((0<0>-.6&"!")+&H6C+h-dinptO)
%>o world!

Each character is used twice!
To run it, you'll need a web server running IIS.
Save it in the site root with a ".asp" extension, make a HTTP request to the server, and you'll see that the response text is exactly "Hello world!" and a new line:
Hello world!

Edit: You could also use this smaller code:
Hel<%= Chr((0<0>we=6&"!")+&H6C+hd)
%>o world!

Or this:
Hel<%= CHr((0<1>wedC=8&"!&")++108)
%>o world!

http://esolangs.org/wiki/Hello%2B%2B
H

1 letter is all it takes to print that

BASH
printf "a\107Vs\x62G8gd29ybGQhCg=="|base64 -d

PHP 5.1.2+
<?="\x48".hasH_file(@cRC32b,__FILE__,'« Tý'|5)." wor\X6Cd!";

The code hashes itself to get the remaining characters. Repeats the characters ".\,'_
A tab messes up the formatting. Base64:

PD89Ilx4NDgiLmhhc0hfZmlsZShAY1JDMzJiLF9fRklMRV9fLCfCqwlUw70nfDUpLiIgd29yXFg2Q2QhIjs=

Nice hack, but I count 4 underscores.

@eBusiness Five _ actually, and four times " :)

newLISP
Such a cruel challenge for a Lisp-like language, where so much is possible if only you don't count parentheses... :) But a solution can be found:
 (eval-string(encrypt {`4?3%;=6^9z*9&^m=>*],c;W}{HDMZKOQX~B2OUJ1MJQX1HBF~KU2FZD}))

(81 characters)
which uses the simple encrypt function to pass a command through to the evaluator. The actual command is (println {Hello world!}). (Having "z" and "Z" and "Z" is allowed, according to the comments...:)).

POSIX shell (Bash et al) - 26 chars
printf 'Hel\x6Co world!\n'

k/q (25 chars)
-1@.h.uh"Hello wor%6cd!";
works in either k or q
(btw, the validity can be checked elegantly with |/#:'="-1@.h.uh\"Hello wor%6cd!\";")

JavaScript (52 characters)
alert(['He\x6C\x6Co world!'][(!1,0)-0], +-1+"Hadtw")

Each character is used 2 times, and it doesn't use any comments!
Edit: I've just posted the same answer here.

c-41
main(){printf("He%clo world!%c",154,10);}

Doesn't work in general: http://codepad.org/O09aQhCe - on what platform does character code 186 give you 'll' ?

In MS-DOS (code page 437 and similar) character with code 186 is double vertical line, used for drawing frames.

It's 38 chars. You missed '!'. Besides, the two vertical bars are not two L's

It produces this output: He||o world! I'm using code blocks

Without ending '\n' this answer contains 35 chars. And output looks wery similar to Hello world!. But this answer may be wroted shorter as main(){puts("He║o world!");}

@AMK thanks I guess adding the vertical bars was a bad idea from the first.

Question states: "exactly outputs the characters Hello world!"

@Darren that's why I edited it.

I don't think you're compiling and running your submission, @user689.  When I compile and run your program, I get the output He%clo world!%c. This is expected, since puts does not allow printf style formatting.

Oops you are right @Darren

JavaScript 35
With inspiration from @VisioN
alert(atob("SGVsbG8gV29y")+'ld!\n')

Tcl, 21 bytes
puts Hello\ wor\x6cd!

Try it online!

SmileBASIC
?@H[1]+@e[!0];CHR$(108);"lo world!

Another solution:
CLS?"He__o world!
LOCATE 2,0?@l[1]*2

In C. Choose one of these.
My favourite (crazy but compact in memory):
#include <stdint.h>
printf("%s", (char*)(int32_t[]){1819043144,1870078063,6581362});

For those who like big numbers:
printf("%s", (char*)(int64_t[]){8031924123371070792,43509902450});

Or here the more descriptive versions:
printf("%s", (char*)(int32_t[]){0x6c6c6548,0x6f77206f,0x646c72});
printf("%s", (char*)(int64_t[]){0x6f77206f6c6c6548,0x0a21646c72});

char map:
H  e  l  l     o     w  o     r  l  d  !     <LF>
48 65 6c 6c    6f 20 77 6f    72 6c 64 21    0a
(remember to swap big/little endian bytes when composing)

Btw: why there is no 128 bit integer in C?
printf("%s", (char*)(int128_t[]){0x0a21646c726f77206f6c6c6548});
printf("%s", (char*)(int128_t[]){802616035175250124568770929992}); // string uses only 100 of 128 bits

These don't met the requirements as some characters are used more than twice. Eg ( ) 0 1 2 9 etc etc

When I look at the example in the question, I see print("He%so world!"%(2*'l')) which is 1p 2r 1i 1n 1t 2( 2" 1H 1e 2% etc. Even when I focus to the string I still see 2 o's, so why should my answer follow the rules when the question doesn't? ;-)

printf("%s", (char*)(int32_t[]){1819043144,1870078063,6581362});
( x 3,  ) x 3, 1 x 5, 3 x 3, 4 x 4, 6 x 3, 8 x 4

Ok, I see. I misunderstood the specs. But I'm not the only one, when I look at the bash + ruby solutions of SztupY and the solution of cnst

Just because someone else didn't follow the rules doesn't justify you.

AWK and echo
EDIT:   fix the extra o's following the note. (thanks ProgramFOX)
echo He: | awk -F: '{print $1,Q,"\157 Wor",Q}' OFS=l ORS=d\!

and thanks awk which give me the option to say "-F" instead of "IFS="
(:-)

There are too many spaces, too. after echo, after He:, after |, and so on.

Java
Okay I found this on SO, it doesn't output a big H
Rare sequence of random stream of digits for 2 specific seeds.
Probably fixed out by brute forcing
One of the SO solutions also include a brute forcer to make your own sequences.
System.out.println(randomString(-229985452) + " " + randomString(-147909649) + "!");

And randomString() looks like this
public static String randomString(int i)
{
    Random ran = new Random(i);
    StringBuilder sb = new StringBuilder();
    for (int n = 0; ; n++)
    {
        int k = ran.nextInt(27);
        if (k == 0)
            break;

        sb.append((char)('`' + k));
    }

    return sb.toString();
}

Source: https://stackoverflow.com/questions/15182496/why-does-this-code-print-hello-world

And this meets the specs, how? I can easily count 3 S's, 3 spaces, 3 2's, etc.

authors: Bob Jarvis - Слава Україні


text:
Convert radicals to mixed & entire radicals and to real numbers
Challenge
The goal of this challenge is to take a radical and convert it to a reduced and entire radical, and a real number. You do not have to convert it to all 3, however, you will get bonus points for converting it to 2 or 3 of them. You will also get bonus points if your code works not just with square roots. How the input works is your choice. You don't have to parse the input so you could just have it as a function. If your unable to output the root symbol (√) then you could output it as sqrt(x) or cuberoot(x). You could also use a superscript (²√) for the index of the radical.
Rules

If you just output one of the 3 options, then you can't just output it without converting it (ie: if the input is √125 then you can't just output √125 back).
The entire radical must have no co-efficient.
The mixed radical must have a coefficient (if there is no coefficient, then it should be 1).
The real number (or result of the radical) should have as many decimals as possible.

Example
Here's an example output for the square root of 125 (√125):
Entire radical: √125
Mixed radical: 5√5
Real number: 11.18033988749895

Scoring

10% off your score for outputting 2 of either an entire radical, mixed radical, or real number.
30% off your score for outputting all 3 (entire radical, mixed radical, and real number).
30% off your score for working with a radical with any index

Winner
The person with the shortest code length wins. Good luck!

What is the first enumerated rule supposed to mean? Specifically: 1. Does it imply that the solution must accept input in the form of an entire radical? 2. Is that the only input form which must be supported? 3. If a program only outputs entire radicals, and an entire radical is supplied as input, what should the program do? Not output anything?

You may also want to specify, that the coefficient for mixed radicals is not always 1 but the maximum integer value.

APL, 77 × .7² = 37.7
{(a b)←×⌿(∪p)*[1]c,⍪e-⍺×c←⌊⍺÷⍨e←∪⍦p←π⍵⋄q←⍺/⍨⍺≠2⋄∊¨⍕¨¨⍪(q'√'⍵)(a'×'q'√'b),⍺√⍵}

Nars2000. Could be golfed some more, for instance by printing worse output, but I'm being lazy.
Also, pretty output is pretty.
Ungolfed
{
  p←π⍵                       ⍝ prime factors of the radical argument ⍵
  u←∪p                       ⍝ unique prime factors
  e←∪⍦u                      ⍝ exponents of those factors (so that ⍵=u*e)
  r←⌊e÷⍺                     ⍝ u's exponents for the reduced radical factor
  f←×/u*r                    ⍝ reduced radical factor
  a←×/u*e-⍺×r                ⍝ reduced radical argument
  i←⍺/⍨⍺≠2                   ⍝ index, unless it's 2 (AH THE DECADENCE, I CAN WASTE SO MUCH)
  o←(i'√'⍵)(f'×'i'√'a),⍺√⍵   ⍝ the three expressions to output
  ∊¨⍕¨¨⍪o                    ⍝ return them as a table without spaces
}

Examples
     2 f 125
√125
5×√5
11.18033989
     2 f 1440
√1440
12×√10
37.94733192
     3 f 1440
3√1440
2×3√180
11.29243235
     2 f 987654321
√987654321
51×√379721
31426.96805

Would it not cost fewer bytes to only do two tasks?

C (314)
n,d;main(i){scanf("%d %d",&n,&d);int val[d];for(;pow(i,n)<=d;i++)val[i]=pow(i,n);printf("Entire radical: %drt(%d)\n",n,d);for(i--;i>0;i--)if(d%val[i]==0){printf("Mixed radical: %d*%drt(%d)\n",i,n,d/val[i]);break;}double v,x=1.5,a=d;do{v=(a/pow(x,n-1)-x)/n;x+=v;}while(abs(v)>=1E-9);printf("Real number: %lf\n",x);}

Here it is with whitespace.
n,d;
main(i){
    scanf("%d %d",&n,&d);
    int val[d];

    for(;pow(i,n)<=d;i++)
        val[i]=pow(i,n);

    printf("Entire Radical: %d*rt(%d)\n",n,d);

    for (i--;i>0;i--)
        if (d%val[i]==0){
            printf("Mixed Radical: %d*%drt(%d)\n", i, n, d/val[i]);
            break;}

    double v,x=1.5,a=d;
    do{
        v=(a/pow(x,n-1)-x)/n;
        x+=v;
    }while(abs(v)>=1E-9);

    printf("Real number: %lf\n", x);
}

Input:
2 125

Output:
Entire radical: 2rt(125)
Mixed radical: 5*2rt(5)
Real number: 11.180340

Input:
3 125

Output:
Entire radical: 3rt(125)
Mixed radical: 5*3rt(1)
Real number: 5.000000

This isn't perfect, the root calculation will not work for all input values, and the chosen guess value is not random. It takes the whole value of the radical as input (see above).

C - 222 × 70% × 70% ≆ 108.78
p,c=1,i,n=2,t;main(){scanf("%d %d",&i,&p);printf("Entire radical: rt%d(%d)\nReal number: %.16
lf\n",i,p,pow(p,1.0l/i));for(;n++<p;t=0){for(;!(p%n);t++)p/=n;c*=pow(n,t/i);p*=pow(n,t%i);}pr
intf("Mixed root: %drt%d(%d)",c,i,p);}

Has some problems with rounding, but is otherwise fine.

Ruby, 199 chars * 70% * 70% = 97.51
I'm not good at mathstuffs. :P
a,b=gets.split.map &:to_i
c=b
[*2..o=b].map{|x|x**a}.map{|x|o=c/=x if c%x==0}until o==b
puts"Entire radical: #{a}rt#{b}
Mixed radical: #{((b/c)**(1.0/a)).round}*#{a}rt#{c}
Real number: #{b**(1.0/a)}"

I particularly like line 3. It's supposed to keep dividing out squares until it can't divide anymore. How I did it is that o is set to b in the beginning (conveniently tucking it into the range expression), and if a square can be divided out, o is set to the result (also conveniently only adding 2 more characters). Then, I used until o==b, so that it keeps going until o didn't change (meaning no squares could be divided out).
More explanations coming soon....

Sample runs:
c:\a\ruby>radicalstuffs
2 100
Entire radical: 2rt100
Mixed radical: 10.0*2rt1
Real number: 10.0

c:\a\ruby>radicalstuffs
2 125
Entire radical: 2rt125
Mixed radical: 5*2rt5
Real number: 11.180339887498949

c:\a\ruby>radicalstuffs
2 100
Entire radical: 2rt100
Mixed radical: 10*2rt1
Real number: 10.0

c:\a\ruby>radicalstuffs
5 32
Entire radical: 5rt32
Mixed radical: 2*5rt1
Real number: 2.0

c:\a\ruby>radicalstuffs
3 27
Entire radical: 3rt27
Mixed radical: 3*3rt1
Real number: 3.0

c:\a\ruby>radicalstuffs
2 99
Entire radical: 2rt99
Mixed radical: 3*2rt11
Real number: 9.9498743710662

c:\a\ruby>radicalstuffs
2 98
Entire radical: 2rt98
Mixed radical: 7*2rt2
Real number: 9.899494936611665

Julia, 19*0.9 = 17.1
julia> f(n)="$(sqrt(n)) √$n"

julia> f(125)
"11.180339887498949 √125"

I feel like I must not have understood the challenge. As far as I could tell there is only a small bonus for bothering to reduce the radical.

source: Stack Exchange

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

sort: votes


text:
Period of the decimal representation
Write a function which takes a single positive integer n and returns the period of the decimal representation of 1/n.
Test cases:
1 -> 1               # 1/1 = 1.0000...... = 1._0
2 -> 1               # 1/2 = 0.5000...... = 0.5_0
3 -> 1               # 1/3 = 0.3333...... = 0._3
7 -> 6               # 1/7 = 0.14285714.. = 0._142857
13 -> 6
14 -> 6
123 -> 5
345 -> 22
654 -> 108
12345 -> 822
67890 -> 120

This is code-golf. Built-ins or libraries which return the period directly are not permitted. Numbers up to at least 100000 should work within reasonable time (at most several minutes).

The question states that "numbers up to at least 100000 should work within reasonable time", but does the program have to give the right answer for numbers larger than this? Or would it be acceptable to use an algorithm that is only accurate up to 100000?

@FireFly Algorithms must provide the correct answer.

Why would 1 return 1? I would think 0?

@Timtech 1.00000000000000000000000000000000000

@Cruncher Oh thanks, I get it now.

I think the output for 1 and 2 should be 0, not 1.

A051626, but all 0s are replaced with 1s

APL, 19 chars/bytes*
{(↑⍳⍨1∘↓)⌽⍵|10x*⍳⍵}

Nars2000. The previous version was wrong on some numbers, this should be right. I manually checked it on all numbers up to 50.
Again, credit goes to Ben Reich for the idea of looking at the period of 10^i (mod x)
Exploded view
{                     ⍳⍵}   generate all naturals up to the argument ⍵
                 10x*       raise 10 to each of them, with unlimited precision
              ⍵|            compute the respective remainders mod ⍵
            ⌽               reverse the list
 (  ⍳⍨    )                 (fork) find the position of the first occurrence
  ↑                         of the fist element of the list
       1∘↓                  in the remainder of the list

Examples
      {(↑⍳⍨1∘↓)⌽⍵|10x*⍳⍵}¨1 2 3 7 13 14 123 345 654 12345 67890
1 1 1 6 6 6 5 22 108 822 120

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
*: APL can be written in its own (legacy) single-byte charset that maps APL symbols to the upper 128 byte values. Therefore, for the purpose of scoring, a program of N chars that only uses ASCII characters and APL symbols can be considered to be N bytes long.

I can't get the correct answer for e.g. input 20. Can you please verify?

I followed the examples you posted. In your example, 1/2 = 0.5 -> 1, so naturally 1/20 = 0.05 -> 2. What are you getting?

The correct answer would be 1, since 1/20 = 0.05_0_.

I see. Give me a bit, I'll revise my answer.

4 seems that it would give the wrong answer too, because 10 != 100 (mod 4).

Yes, apparently I had misunderstood the question, nonetheless I had come up with a formula that passed all the test cases! I'll revise my answer as soon as I can work on it.

@Tobia I assume that you have to remove all factors 2 and 5 from the input (as they are prime factors of the base).

Now it's ok. The previous version was computing the period only when there were no non-repeating decimals, otherwise it computed the number of non-repeating decimals (1/8 = 0.125_0_ would give 3) Don't ask me how I came up with that!

It wasn't even doing that. On 12 it would find two distinct remainders (100 = 1000 = 4 (mod 12)).

GolfScript (42 27)
{:x)1\[{.10*x%}*]-1%(?)}:P;

Benchmark time: 5 secs. Benchmarking code:
'"The time is #{Time.now#1
}"'~ puts
[1 2 3 7 13 14 123 345 654 12345 67890 99991]{[P]p}%
'"The time is #{Time.now#2
}"'~ puts

Credit to Ben Reich for the core idea of looking at the period of 10^i (mod x).
Explanation
The period p is defined as the smallest positive integer such that for all sufficiently large i we have frac(10^i * 1/x) = frac(10^(i+p) * 1/x). We can simplify that slightly to frac(10^i / x) = frac(10^(i+p) / x). Now, frac(a / x) = frac(b / x) iff a == b (mod x), so we're looking for the smallest positive integer such that for all sufficiently large i: 10^i == 10^(i+p) (mod x).
Suppose 10^i == 10^(i+p) (mod x). Then 10^(i+1) == 10 * 10^i == 10 * 10^(i+p) == 10^(i+p+1) (mod x); so once we get a repetition, we're in an unbreakable cycle.
There are only x distinct values (mod x), so by the pigeonhole principle we must get a repetition in the first x + 1 values of 10^i (mod x).
So what the code above does is to compute x + 2 values of 10^i (mod x)*. Then the last one is guaranteed to be a repetition, and by reversing the list and searching for it I can find the most recent occurrence. Moreover, because I'm only doing the one search this is pseudolinear time.
* The extra one is to handle the special case x = 1, because I don't reduce 10^0 (mod x) and so I'd be looking for a 0 in [1].

Awesome! I've deleted my answer since a better solution! –

Golfscript - 26 bytes
{:i.)+.,{;10*i%.}%i>|,}:f;

Edit: updated to output 1 if the decimal terminates, rather than the length of the decimal representation.
A fairly efficient version. The value 67890 runs in approximately 10 seconds, and 99991 around 20 seconds. It's a bit slower than it was before (roughly half as fast), because the range that is iterated has been doubled, the first half of which is ignored.
Alternative, also 26 bytes
{:i.)+.n*{*i%.}%i>)^^,}:f;

This one works by iterating over the string "\n"*(2*i+1), where i is the value passed to the function. The value passed to the block each time is the ordinal value of "\n", which is 10.
The )^^ is a bit of a work-around. When you uncons a character from a string, the result is the ordinal value of the character removed, as mentioned above. However, appending that value back on will append the string representation of that number, rather than the character - fairly nonsymmetric behavior, and in my opinion a design flaw. If you actually wanted to do that, stringifying first would only cost one byte.
An extra copy of the final value is already on the stack, so I remove the final value again ), xor it with the string, and then xor it again, so that any characters which were added or removed by the first xor are restored. If int op string were treated as a character, rather than its string representation, )^^ could be replaced by |.
Note that while strings (which in Golfscript are stored as an array of ints) will display the value of each character mod 256, the values of each character may themselves be outside this range. When testing for uniqueness (via set operations) or containedness (via ?), it is the actual value that is compared, rather than the display value.
A patch file for the current Golfscript interpreter:
61c61
<       to_gs
---
>       Gstring.new([self])

The above will only affect the behavior of string op int (and vice versa), where op is one of
+-|&^. Everything else remains unaffected, including the behavior of Gint`.
The following 24 byte solution would then become valid:
{:i.)+.n*{*i%.}%i>|,}:f;

And this also fixes a lot of other really ugly work-arounds.

Python - 48 bytes
f=lambda n:len(set(10**-~i%n for i in range(n)))

Not the most efficient solution, but reasonable for values less than 100000.
FWIW, the core element is identical to my solution for Generate cyclic numbers in decimal.
A more efficient version of the same code (70 bytes):
 def f(n):
  a=[];i=10%n
  while i not in a:a+=i,;i=i*10%n
  return len(a)

The value 99991 takes less than a second.

@PeterTaylor it ors the array onto an empty string. Because it's a set-wise operation, all duplicates are removed beforehand.

But where does the empty string come from? If the function is to be self-contained I think you're going to have to spend an extra byte and make it .|.

@PeterTaylor fixed.

Changing the behaviour of string int + would break a lot of programs. I'm not sure how often the other ops are used on that type pair.

@PeterTaylor I agree, it would. But consider: convert int to char: []+''+ vs ''+. Append int, as char, to string: []++ vs +. Apend int, as string representation, to string: + vs \+. In it's current implementation, int''+is synonymous toint``, which seems wasteful considering the verbosity of having to coerce to array, and then coerce to a string if you want the ascii char.

Also this version breaks on input 20.

@Howard I agree. The correct answer should be 0.

@primo The correct answer would be 1.

I understand that this is your expected output. But I also believe that it is categorically incorrect to say that the period length of 1/20 is 1. This would indicate that the value were 0.0(5...), which it isn't.

@primo Well, that's the way most people define it. And you may write 0.05(0) instead which is clearly better ;-)

@Howard One may also write 0.05(00). "This isn't the minimum period length!", you might say. One isn't either. The minimum period length is zero.

@primo I won't discuss this any further ;-) It is 1 by definition.

GolfScript, 48 47 46
Thanks to @PeterTaylor for chopping two chars off.
{2{1$1$%!{.@\/\d}*}:d~;5d;9{2$%}{10*9+}/+,}:f;

I tried using J, but it kept giving me all sorts of strange results.
Test online
This basically divides 2 and 5 out of the number (2 and 5 are the prime factors of 10, and their reciprocals terminate, and stuff up the algorithm), then the lowest integer n such that the resulting number divides 10^n - 1 is the period.

If you know which will be the first call to your function then you can inline the definition there. I.e. instead of {...}:d;...d you save 1 char with ...{...}:d~

@PeterTaylor thanks, hadn't thought of that

Having commented to Ben about not leaving f on the stack, I notice that you're doing it too. You should really add a ; to pop the function for fair comparison with other languages.

Another micro-optimisation: int array ,)\; can be shortened to int array +,.

Perl, 52 characters
sub f{($p,%r)=1;1until$r{$p=$p*10%$_[0]}++;~~keys%r}

This is an uncomplicated implementation of the direct approach. (Fortunately the direct approach is also pretty efficient: thanks to modulo arithmetic, the math never has to deal with a number more than 10 times the input value.)
Since the challenge specified a function, I felt compelled to (re-)initialize my variables, something I wouldn't bother doing for a complete program. Likewise, the ~~ in the final statement is unnecessary if the function can be certain it will be invoked in a scalar context.

Try on input 20 where it yields the wrong result.

Clojure, 102, 117, 115, 106
unformated:
(defn r([n](r{}(iterate #(mod(* % 10)n)10)0))([a[f & s]i](if(a f)(- i(a f))(recur(assoc a f i)s(inc i)))))

formatted:
(defn r
  ([n] (r {} (iterate #(mod (* % 10) n) 10) 0))
  ([a [f & s] i]
    (if (a f)
      (- i (a f))
      (recur
        (assoc a f i)
        s
        (inc i)))))

Running time scales with the period.  Almost instantaneous on my computer for the sample values.
Basically, this calculates the result of the subtraction after each step in long division.  A cycle is detected if at any point that number is the same as one that has been calculated before it.

The code breaks with input 20. Can you please verify?

You are right,  the above solution is faulty.  Gonna see if I can fix it.

What is the expected output for 20?

The correct answer would be 1.

Should be good to go, first algorithm would fail on lots of inputs, for example 12 and 20.

Pyth, 13 bytes
fq.^;yTQ.^;TQ

Uses turtle-and-hare algorithm (more information).
Watch it pass every test.

05AB1E, 9 bytes
ÌLR°I%ćk>

Port of @PeterTaylor GolfScript answer, so make sure to upvote him as well!
Try it online or verify almost all test cases. The last test case is omitted, which takes little over a minute.
If we want to output all test cases in less than a second, a port of @primo's Python answer could be used, which comes in at 14 bytes with a minor alternative of the same approach using a cumulative right-reduce:
>LTªÅ«T*I%}ćk>

Try it online or verify all test cases.
Explanation:
Based on the input \$n\$, I first generate a list within the range \$[n+1,1]\$. And then find the first 1-based index of a value \$x\$ which is truthy for \$10^x\pmod n=10^{n+2}\pmod n\$.
Ì          # Increase the (implicit) input-integer by 2
 L         # Pop and push a list in the range [1,input+2]
  R        # Reverse it to the range [input+2,1]
   °       # Map each value to 10 to the power that value
    I%     # Modulo the input
      ć    # Extract head; pop and push remainder-list and first item separately
       k   # Get the 0-based index of this 10**(input+2) in the list of
           # [10**(input+1),10**input,...,100,10]
        >  # Increase this by 1 to make it a 1-based index
           # (which is output implicitly as result)

>L         # Push a list in the range [1,input+1]
  Tª       # Append a trailing 10
    Å«     # Cumulative right-reduce, keeping all intermediate results:
      T*   #  Multiply the current integer by 10
        I% #  Modulo the input
     }     # After the right-reduce:
      ćk>  # Get the 1-based index of the extracted head, similar as above
           # (which is output implicitly as result)

Vyxal r, 8 bytes
⇧ɾṘ↵%ḣḟ›

Try it Online!
Port of 05AB1E.
How?
⇧ɾṘ↵%ḣḟ›
⇧ɾ        # Push range [1, (implicit) input + 2]
  Ṙ       # Reverse to make it range [input + 2, 1]
   ↵      # Map each value to 10 to the power of it
    %     # Modulo by the (implicit) input
     ḣ    # Head extract, push a[0] and a[1:]
      ḟ   # Get the index of this a[0] in this a[1:]
       ›  # Increment to make this a one-based index

PARI/GP, 33 bytes
n->znorder(Mod(10,n/gcd(n,10^n)))
Attempt This Online!

Stax, 7 bytes
üpßN▲╞§

Run and debug it
Approach:

Multiply by 10
Keep only fractional part
Repeat until a loop of values is found
Keep only the loop
Get the length

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

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


text:
Find the beats in an MP3 file
In this challenge, your task is to take an simple recording in mp3 format and find the time offsets of the beats in the file. Two example recordings are here:
https://dl.dropboxusercontent.com/u/24197429/beats.mp3
https://dl.dropboxusercontent.com/u/24197429/beats2.mp3
Here is the third recording with much more noise than the two previous:
https://dl.dropboxusercontent.com/u/24197429/noisy-beats.mp3
For example, the first recording is 65 seconds long and contains exactly (unless I miscounted!) 76 beats. Your job is to devise a program that takes such an mp3 file as input and outputs a sequence of the time offsets in milliseconds of the beats in the file. A beat is defined to occur, of course, when the guitarist playing plucks one or more strings.
Your solution must:

Work on any mp3 file of similar "complexity". It can fail on to noisy recordings or to quickly played melodies -- I don't care.
Be fairly precise. Tolerance is +/- 50 ms. So if the beat occurs at 1500 ms and your solution reports 1400, then that is unacceptable.
Use only free software. Calling ffmpeg is allowed as is using any freely available third party software for your language of choice.

The winning criteria is ability to successfully detect beats despite noise in the supplied files. In case of a tie, the shortest solution wins (length of 3rd party code isn't added to the count).

Even though this looks interesting, this is a contest, you should define winning criteria more precisely than "Correctness".

ok better now??

A good contest isolates the part of interest. Here you seem to be interested in beat identification, which is certainly an interesting DSP problem. So why make the programs handle (or outsource) the complexities of the MP3 file format? The question would be improved by taking either RAW (with permitted assumptions about sample rate, bit depth, and endianness) or WAV (similarly).

The point of the contest is to handle all those pieces. Perhaps that makes it hard to solve it in golfscript if it has a hard time interfacing with mp3's. Never the less, the challenge is well-specified and (afaict) completely on-topic so the negativity is very dismaying.

@BjörnLindqvist You shouldn't take suggestions for improvement to heart. Unless some previous comment has been deleted, I don't see any negative comments here, just suggestions for improvements.

@Gareth I believe OP is worried about the downvotes (post has +3/-2). These occured before the latest edit (source: http://codegolf.stackexchange.com/posts/18543/timeline/).

I'm voting to close this as unclear because "similar complexity" is not even close to being objective.

Why is that unclear?

Python 2.7 492 bytes (beats.mp3 only)
This answer can identify the beats in beats.mp3, but will not identify all notes on beats2.mp3 or noisy-beats.mp3. After the description of my code, I'll go into detail as to why.
This uses PyDub (https://github.com/jiaaro/pydub) to read in the MP3. All other processing is NumPy.
Golfed Code
Takes a single command line argument with the file name. It will output each beat in ms on a separate line.
import sys
from math import *
from numpy import *
from pydub import AudioSegment
p=square(AudioSegment.from_mp3(sys.argv[1]).set_channels(1).get_array_of_samples())
n=len(p)
t=arange(n)/44.1
h=array([.54-.46*cos(i/477) for i in range(3001)])
p=convolve(p,h, 'same')
d=[p[i]-p[max(0,i-500)] for i in xrange(n)]
e=sort(d)
e=d>e[int(.94*n)]
i=0
while i<n:
 if e[i]:
  u=o=0
  j=i
  while u<2e3:
   u=0 if e[j] else u+1
   #u=(0,u+1)[e[j]]
   o+=e[j]
   j+=1
  if o>500:
   print "%g"%t[argmax(d[i:j])+i]
  i=j
 i+=1

Ungolfed Code
# Import stuff
import sys
from math import *
from numpy import *
from pydub import AudioSegment

# Read in the audio file, convert from stereo to mono
song = AudioSegment.from_mp3(sys.argv[1]).set_channels(1).get_array_of_samples()

# Convert to power by squaring it
signal = square(song)
numSamples = len(signal)

# Create an array with the times stored in ms, instead of samples
times = arange(numSamples)/44.1

# Create a Hamming Window and filter the data with it. This gets rid of a lot of
# high frequency stuff.
h = array([.54-.46*cos(i/477) for i in range(3001)])
signal = convolve(signal,h, 'same') #The same flag gets rid of the time shift from this

# Differentiate the filtered signal to find where the power jumps up.
# To reduce noise from the operation, instead of using the previous sample,
# use the sample 500 samples ago.
diff = [signal[i] - signal[max(0,i-500)] for i in xrange(numSamples)]

# Identify the top 6% of the derivative values as possible beats
ecdf = sort(diff)
exceedsThresh = diff > ecdf[int(.94*numSamples)]

# Actually identify possible peaks
i = 0
while i < numSamples:
 if exceedsThresh[i]:
  underThresh = overThresh = 0
  j=i
  # Keep saving values until 2000 consecutive ones are under the threshold (~50ms)
  while underThresh < 2000:
   underThresh =0 if exceedsThresh[j] else underThresh+1
   overThresh += exceedsThresh[j]
   j += 1
  # If at least 500 of those samples were over the threshold, take the maximum one
  # to be the beat definition
  if overThresh > 500:
   print "%g"%times[argmax(diff[i:j])+i]
  i=j
 i+=1

Why I miss notes on the other files (and why they are incredibly challenging)
My code looks at changes in signal power in order to find the notes. For beats.mp3, this works really well. This spectrogram shows how the power is distributed over time (x axis) and frequency (y axis). My code basically collapses the y axis down to a single line.

Visually, it's really easy to see where the beats are. There's a yellow line that tapers off again and again. I highly encourage you to listen to beats.mp3 while you follow along on the spectrogram to see how it works.
Next I'll go to noisy-beats.mp3 (because that's actually easier than beats2.mp3.
.
Once again, see if you can follow along with recording. Most of the lines are fainter, but still there. However, in some spots, the bottom string is still ringing when the quiet notes start. That makes finding them especially hard, because now, you have to find them by changes in frequency (the y axis) rather than just amplitude.
beats2.mp3 is incredibly challenging. Here's the spectrogram

In the first bit, there some lines, but some notes really bleed over the lines. To reliably identify notes, you'd have to start tracking the pitch of the notes (fundamental and harmonics) and seeing where those change. Once the first bit is working, the second bit is twice as hard as the tempo doubles!
Basically, to reliably identify all of these, I think it takes some fancy note detection code. Seems like this would be a good final project for someone in a DSP class.

I think this is not allowed, because it doesn't fulfill all the requirments.  Good answer, but it needs some work.

Yeah, I'm a bit disappointed this method didn't work out as I hoped. I figure this might help someone else who wants to take a stab at it. If I get some spare time this week, I hope to try a new FFT based approach that should give better results.

Okay, cool.  Nice job though.


text:
Flippin' Squares
Create a program or function to unjumble a square of digits by flipping (reversing around the centre point) only rows and columns.
Input
Input will be a 9x9 grid of digits in the form of a 9 line string like the following:
986553229
264564891
759176443
643982153
567891234
526917874
685328912
891732537
117644378

This input format is non-negotiable - any solutions which are "creative" with the input format will be considered invalid.
Output
Output should be a list of flip moves which, when applied to the input in the given order, should recreate the target grid.
An example output (not a solution to the previous input example):
28IF5D3EAB9G3

This output format is also non-negotiable. There should be no newlines or spaces in the output, only the characters 1-9 and A-I (lower case characters are acceptable in place of upper case characters if you prefer).
The target grid (the state you need to recreate) is as follows:
123456789
234567891
345678912
456789123
567891234
678912345
789123456
891234567
912345678

The numbers 1-9 should be used as instructions to flip the rows, and the letters A-I should be used for the columns. This is shown below with the grid in its restored state.
     ABCDEFGHI
     |||||||||
     vvvvvvvvv
1 -> 123456789
2 -> 234567891
3 -> 345678912
4 -> 456789123
5 -> 567891234
6 -> 678912345
7 -> 789123456
8 -> 891234567
9 -> 912345678

So an 8 means flip the second row from the bottom, and an F means flip the sixth column.
In the case that no solution is possible, the program should end without outputting anything at all.
Examples
Input:
987654321
234567891
345678912
456789123
567891234
678912345
789123456
891234567
912345678

Output:
1

In this case only the top row needs flipping to return to the goal state.
Input:
123456788
234567897
345678916
456789125
567891234
678912343
789123452
891234561
912345679

Output:
I

In this case only the final column (column I) needs flipping to recreate the goal state.
Input:
123456788
798765432
345678916
456789125
567891234
678912343
789123452
891234561
912345679

Output:
2I

In this case we need to flip row 2 and then flip column I to return to the goal state.
Notes:

Please include an example usage in your answer.
The output given does not have to be the shortest sequence that will return the goal state - any sequence which returns the goal state will do as long as it works (i.e. as long as I can test it)
I'll endeavour to test each answer and upvote all those that work and have obviously had an attempt at golfing.
This is an open-ended competition - I'll accept the shortest answer sometime next week, but if a newer valid answer comes along which is shorter at any point in the future I'll change the accepted answer to reflect that.
The bounty has been set at 200 reputation for the shortest answer received by 23:59:59 (GMT) on 26/01/2014 The bounty was awarded to Howard for his 268 character GolfScript solution.

Testing
Please provide your program's output for the following three test grids with your answer:
986553229
264564891
759176443
643982153
567891234
526917874
685328912
891732537
117644378

927354389
194762537
319673942
351982676
567891234
523719844
755128486
268534198
812546671

813654789
738762162
344871987
341989324
567891234
576217856
619623552
194435598
926543271

I've created a small Python program to generate valid grids for testing purposes:
import random

def output(array):
  print '\n'.join([''.join(row) for row in array])

def fliprow(rownum, array):
  return [row[::1-2*(rownum==idx)] for idx,row in enumerate(array)]

def flipcol(colnum, array):
  return zip(*fliprow(colnum, zip(*array)))

def randomflip(array):
  op=random.randint(0,1)
  row=random.randint(0,9)
  if(op==1):
    return fliprow(row, array)
  else:
    return flipcol(row, array)

def jumble(array):
  arraycopy=array
  for i in range(10, 1000):
    arraycopy=randomflip(arraycopy)
  return arraycopy

startarray=[
['1','2','3','4','5','6','7','8','9'],
['2','3','4','5','6','7','8','9','1'],
['3','4','5','6','7','8','9','1','2'],
['4','5','6','7','8','9','1','2','3'],
['5','6','7','8','9','1','2','3','4'],
['6','7','8','9','1','2','3','4','5'],
['7','8','9','1','2','3','4','5','6'],
['8','9','1','2','3','4','5','6','7'],
['9','1','2','3','4','5','6','7','8']]

print output(jumble(startarray))

I just wrote a short solution that randomly flipped rows/columns until the sort was complete.  After 500 million iterations it still had not solved the first puzzle you gave (where you only need to flip row 1).  Randomness does not appear to be a usable solution to this problem!

@Josh Not surprising. This problem appears to be very similar to solving a rubik's cube. I think some kind of breadth-first search would be the best brute force. That being said, the random algorithm theoretically has to terminate eventually, and appears to fit the rules specified.

The brute force would take 90^x, where x is the number of moves it takes to find the optimal solution, iterations. Does anyone know how many moves the optimal solution is on average? I guess memoization of already considered states helps a bit

Brute force isn't needed.  Consider the fact that each grid tile can only end up in one of four positions: its correct location, flipped X, flipped Y, or flipped XY.  It may help you to mentally treat the grid as having (0,0) being the center-most tile.  If you're solving tile (-2, 4), the only locations the target number could be is (-2, 4), (2, 4), (2, -4), or (-2, -4).

@GigaWatt I don't think that's true. I can get the upperleftmost 1 into any square, so I'm not sure exactly what you're conjecturing.

@Cruncher How do you do that?

@Cruncher: Using whole row/column flips makes that impossible.  For example, try to take the upperleftmost 1 (A1) and move it to B1.  You can get a 1 to the position B1, but it'll be the tile from B9, not the tile from A1.
Because we're only allowed whole row/column flips, the upperleftmost 1 will only ever be in one of the four outermost corners.
If I've mistaken the rules, please let me know.

@GigaWatt You are correct. Using only whole row/column flips means that the number in the upper left most corner will only ever be able to reach the other corner positions.

Is it me, or does the very very first grid have no solution?

@mniip I used the python program given to generate that grid and the other 2 test cases. So either it can be solved or my program is buggy (which is possible, my python is poor :-)

Congratulations, Gareth. This is a very well-designed problem. Also, quite challenging.

@DavidCarraher Thanks. I'm quite looking forward to trying it myself in python (though I may keep that code to myself :-)

@Gareth As you allow for functions, do you allow return instead of output? There is no big difference (for the code), but some languages (like Java) will be able to shave off some chars

@Quincunx Yes, returning a value from the function is acceptable, but it must be a string in the format required.

GolfScript, 300 279 268 characters
n%`{\5,{.9+}%{;.2/\2%},\;''{1${.9/7+7*+}%+:z;}:?~{{.9<77*{\zip\9-}>:Z~{1$!{-1%}*\(\}@%\Z;}/}:E~{:^;{:c;.`{[\E[.^=\8^-=]{.c=\8c-=}%[^c+^8c-+8^-c+16c-^-]{9%49+}%=}+[[]]:K[[8^- 17c-][^9c+]1$]{:s;{[[]s.+.2$+]{1$+}/}%.&}/\,K+0=z?E}5,/}5,/{{+9%)}+9,%''*}9,%={z:u;}*}+1024,/u

Note that this code is extremely slow (also due to heavy code-block manipulation) and might run several minutes. The code is very un-golfscript-ish with lots of variables and explicit loops.
I had written a more analytic solution which ran for less than a second. I completely broke that one during golfing. Unfortunately, I wasn't able to backtrack or repair the code in the last two days. Therefore, I produced this try-and-check version which is shorter anyways.
The answers for the puzzles given above:
1A2C4D9G9G9G9G1C1C1C1C9F9F9F9F1D1D1D1D2A2A2A2A8H8H8H8H2B2B2B2B2C2C8F8F2D2D2D2D3A3A7I7I3B3B7H7H7G7G7G7G3D3D7F7F6I6I6I6I4A4A4A4A6H6H6H6H6G6G4C4C4C4C6F6F4D4D

1AB39I9I1A1A9I9I1B1B9F9F8I8I8I8I2B2B8H8H8G8G8G8G2D2D2D2D3A3A3A3A7H7H7H7H3C3C3C3C3D3D7F7F6I6I4A4A6I6I4B4B4B4B6G6G4C4C4C4C6F6F6F6F4D4D

1A34D9I9I9I9I1A1A1A1A1B1B1B1B9G9G1C1C1C1C9F9F9F9F1D1D9F9F8I8I2A2A2A2A8H8H8H8H2C2C2C2C8F8F2D2D8F8F7I7I7I7I3A3A3B3B7G7G7G7G3C3C3C3C6I6I6I6I6H6H6H6H4B4B4B4B6G6G6G6G4C4C6G6G6F6F4D4D6F6F

Well, it's going to be pretty hard work beating this...

Seems I was wrong...

@Gareth I knew this is a challenge which would be hard with golfscript against e.g. mathematica.

@Howard - what approach did you use? What is 'try-and-check version' you mentioned?

Mathematica 582 575 503 464 282
To fight with golfscripters I have to use heavy artillery!
i = "986553229
264564891
759176443
643982153
567891234
526917874
685328912
891732537
117644378";

a=Array;h@M_:=Join@@a[9(M〚##〛/. 9->9⌈2Random[]⌉)+Abs[{##}-5]&,n={9,9}];
For[i_~t~j_:=i{#2,10-#2}+j#-9&~a~{9,4},!ListQ[e=GroupElementToWord[
PermutationGroup[Cycles/@Join[1~t~9,9~t~1]],
h[ToCharacterCode@StringSplit@i-48]~FindPermutation~h@a[Mod[8+##,9,1]&,n]]],];
e~IntegerString~36<>""

Output:
g69g69g8g8g7g7gd96d96d8d8d7d7dh6h64a6a46d6d4g4g6b6b7h7h7c7c2a8a27b7bd8db8b7f7fg8g82c2c94a4a3a3aigfdc91

Here PermutationGroup[...] sets up possible flips and GroupElementToWord[...] solves the problem (about 0.2 sec). The main problem is that it is difficult to identify the correspondence between the position of 9 in the initial and the final grid. For golfing I do it randomly (it takes several seconds). There are some warnings but one can ignore them.
Other to test grids:
g69g69g8g8g7g7gh89h89h7h7h6h6hf6f6g6g64f4f4h4hg7g73g3g2a8a28d8db8b83d3dg8g82c2c9a3a643a3a2g9f9d9c9ga
h89h89h7h7h6h6h6h6h6f6f6g6g6d6d3a7a37g7g7h7h3c3c2a8a27b7b8d8d2f2f8b8b3f3f2b2ba2a764a8aih9g9c9gb1i

It completely reproduces the examples:
1
i
2i

Previous solution (464)
without any clever built-in functions and with runtime 4 ms:
M=ToCharacterCode@StringSplit@i-48;
S="";s=Signature;H=(S=S<>{#,#2+9}~IntegerString~36)&;
A=(m=M〚##〛)-9Mod[m+##,2]&[s@{2#3,5}#,2#2#3~Mod~2-#2]&~Array~{4,4,4};
u=s/@Join@@A;
H@@({k,l}=#&@@@#~Position~1&/@{v=u〚13;;〛;{h=#2u〚2〛,-#u〚5〛,-#u〚9〛}&@@v,v〚4〛=u〚4〛h;v});
A〚k〛=A〚k,;;,{2,1,3,4}〛;A〚;;,l〛=A〚;;,l,{3,2,1,4}〛;
MapIndexed[4#≠#4&&H@@@If[#2<3,#0[#3,#,#2,#4];k,#0[#,#3,#4,#2];10-k]&@@
If[s@#<0,#〚{1,3,2,4}〛,#]&@Ordering[k={#2,#2};#]&,A,{2}];
M〚5,1〛<5&&5~H~{};M〚1,5〛<5&&{}~H~5;S

All new lines here are not necessary.
Output:
3b9i9i1a1a1a1a9i9i1a1a9h9h1b1b1b1b9h9h9g9g1c1c9g9g9f9f1d1d9f9f8h8h2b2b8f8f8f8f7i7i7h7h3b3b3b3b7h7h3b3b7h7h7g7g3c3c7g7g3c3c7f7f6i6i4a4a6h6h4b4b4b4b6g6g4c4c6g6g4c4c6f6f4d4d4d4d6f6f4d4d6f6f4d4d

Other two test grids:
13ab9i9i1a1a9i9i9h9h1b1b1b1b9h9h9f9f8i8i8i8i8h8h2b2b2b2b8h8h8h8h8g8g8g8g8f8f2d2d2d2d8f8f2d2d7i7i3a3a3a3a7i7i7h7h3b3b7h7h3b3b7g7g3c3c3c3c7g7g3c3c7f7f3d3d3d3d7f7f7f7f6i6i4a4a6i6i6h6h4b4b4b4b6h6h4b4b6g6g4c4c4c4c6f6f4d4d4d4d6f6f4d4d6f6f
2bc9i9i1a1a9i9i9g9g1c1c9g9g1c1c9f9f1d1d1d1d8i8i8i8i8h8h2b2b2b2b8f8f2d2d7i7i7h7h3b3b3b3b7h7h3b3b7g7g3c3c7f7f3d3d3d3d7f7f3d3d6i6i4a4a4a4a6h6h4b4b6g6g6g6g6f6f4d4d

Visualization:
anim = Reap[Fold[Function[{m, i},
 If[i > 9, (Sow@Grid[#, Background -> {i - 9 -> Pink, None}] & /@ {m, #}; #) &@
   Transpose@MapAt[Reverse, Transpose@m, i - 9], (Sow@Grid[#,
         Background -> {None, i -> Pink}] & /@ {m, #}; #) &@
   MapAt[Reverse, m, i]]], M, IntegerDigits[FromDigits[S, 36], 36]]];

ListAnimate[Join[{#, #} &@Grid@M, anim[[2, 1]], {#, #} &@Grid@anim[[1]]], 5]

The input string i can be generated randomly by
M = Array[Mod[8 + ##, 9, 1] &, {9, 9}];
(M[[#]] = Reverse@M[[#]]; M[[All, #2]] = Reverse@M[[All, #2]];) & @@@
   RandomInteger[{1, 9}, {10000, 2}];
i = ToString /@ # <> "\n" & /@ M <> ""

Brief discussion

Flips can interchange only these elements ("quadruple"):

It is possible to interchange these elements separately from other elements only if the initial and the final order has the same signature.
Flips of these four elements form the alternating group of degree 4 ( = group of rotations of the tetrahedral). Every element of this group is a composition of 2 generating elements. So if we know the initial and final position we can decompose the corresponding transformation as a combination of a simple flips.

Details
For sportsmanship I post details before the end of the bounty!
M=ToCharacterCode@StringSplit@i-48;

Convert the string i to the matrix M.
S="";s=Signature;H=(S=S<>{#,#2+9}~IntegerString~36)&;

We will append chars to S. Now it is the empty string. H[i,j] will add the character i (1,2,3,...,9) and the character j (a,b,c,...,i in base-36).
A=(m=M〚##〛)-9Mod[m+##,2]&[s@{2#3,5}#,2#2#3~Mod~2-#2]&~Array~{4,4,4};

I convert elements as

to obtain the target matrix in the following form

Then there are two main steps in my algorithm

Find flips to obtain the signatures as in the target matrix (e.g. the signature of {-7,-1,1,7} is 1 and the signature of {-6,2,-2,6} is -1):
u=s/@Join@@A;
H@@({k,l}=#&@@@#~Position~1&/@{v=u〚13;;〛;{h=#2u〚2〛,-#u〚5〛,-#u〚9〛}&@@v,v〚4〛=u〚4〛h;v});
A〚k〛=A〚k,;;,{2,1,3,4}〛;A〚;;,l〛=A〚;;,l,{3,2,1,4}〛;

Rotate every "quadruple" to obtain the right order:
MapIndexed[4#≠#4&&H@@@If[#2<3,#0[#3,#,#2,#4];k,#0[#,#3,#4,#2];10-k]&@@
If[s@#<0,#〚{1,3,2,4}〛,#]&@Ordering[k={#2,#2};#]&,A,{2}];

It is the most nontrivial part of the algorithm. For example, the transformation 1b1b will convert {-7,-1,1,7} to {-1,1,-7,7}. The transformation 9h9h will convert {-7,-1,1,7} to {-7,7,-1,1}. So we have two maps
{1,2,3,4} -> {2,3,1,4}
{1,2,3,4} -> {1,4,2,3}

and we want to convert an arbitrary ordering {x,y,z,w} to {1,2,3,4}. The simple method is (except a random search)
repeat
{x, y, z, w} -> If[z < 3, {y, z, x, w}, {x, w, y, z}]
until {1,2,3,4}

I can't proof it, but it works!

The last step is
M〚5,1〛<5&&5~H~{};M〚1,5〛<5&&{}~H~5;S

It performs trivial flips of the center row and the center column and return the result.

@Gareth Can I use small characters in the output? It saves me a number of characters.

Yes, I'll accept lower-case characters in the output (I'll change the question to note this). I don't have Mathematica so could some other Mathematica user confirm that the code actually generates the output? I've validated the three test solutions and they are all correct, so +1. Nice job!

Just curious - what is a performance of your approach? Did you test on inputs generated by thousands of flips?

@SergeyS Yes, it takes about 50 ms :)

@Gareth I rewrite my program, could you check the results? My tests have shown that everything is correct.

@ybeltukov Yes, I'm getting the new solutions as valid too.

One of the other answers has raised an interesting question - what output do you get if the input is invalid; a 9x9 grid of 1s for instance?

@Gareth It always returns something. If initial grid is almost correct then the final grid will be close to the target grid. For grid of 1 it returns 5e. I also post a new (I hope final) version where I significantly reduced the number of characters. However, the last one  goes to infinite loop for incorrect grids.

J 487 438
q=:3 :'(>:9|+/~i.9)=/&((,{;/(,.8&-)y){])g'
l=:2 :0
:
o=:o,(m+x){a.
x&(|.@{`[`]})&.v y
)
r=:49 l]
c=:97 l|:
w=:2 :'g=:4 v^:(4=(<m){g)g'
p=:_1=C.!.2@,@:I.@q
t=:2 :'for_i.>:i.3 do.g=:i v^:(p m*i)g end.'
z=:2 :0
'i j I J'=.y,8-y
g=:".'(',(,' ',.,(I.m{q y){,;._1 n),'])^:2 g'
)
d=:3 :0
g=:9 9$".,_ list,' ',.y
o=:''
0 4 w c
4 0 w r
0 1 t c
g=:0 c^:(-.(p 1 0)=p 1 2)g
1 0 t r
for_k.>,{;~i.4 do.0 z';;jcir;irjc;Irjc'k
3 z';;IrJc;JcIr;'k end.o
)

d is a verb which takes a grid string in the specified format and returns a solution string in the specified format.
Example use:
   d '987654321',LF,'234567891',LF,'345678912',LF,'456789123',LF,'567891234',LF,'678912345',LF,'789123456',LF,'891234567',LF,'912345678'
bcda2341a1a1b1b1c1c1d1da2a2b2b2c2c2d2d2a3a3b3b3c3c3d3d3a4a4b4b4c4c4d4d4

Now accepts either newline type.
Solutions to the test grids:
b3a1a11b1bc9c99g9gd9d99f9fb8b8f8f87i7i7h7hc3c3g7g77f7fa6a64b4bh6h6c4c4g6g6d6d6f6f6
cd24a9a91c1c1d1d9f9fa2a2i8i88h8hc2c2g8g82d2d3b3bh7h7d3d37f7fa6a64b4bg6g64d4d6f6f
bc2a9a99i9ic1c1g9g91d1df9f9i8i8b2b2h8h82c2cd8d87i7ib3b3c7c7d3d34a4ai6i6b6b6g6g6d6d6

I'm fairly new to J; this could probably be golfed even further.

Checking for invalid/unsolvable grids incurs a 123 character penalty. I don't think the other answers to date have such error checking.
To do so, change the first line of d to this:
if.-.+./89 90=#y do.0 return.end.if.-.*./(/:~y)=/:~(#y)$'123456789',LF do.0 return.end.g=:9 9$".,_ list,' ',.y

and the last line to this:
3 z';;IrJc;JcIr;'k end.if.*./,g=>:9|+/~i.9 do.o return.end.0

I've chosen to return 0 on such errors as returning an empty string would be indistinguishable from correctly solving a fully solved grid. Note that this assumes UNIX newlines (again).

Congratulations, you've just gone into the lead. :-)

Looks like your input is not one string as required by rules, or I miss something?

@SergeyS: You might be confused. As far as I know, J has no way of placing escapes (such as newline) in string literals. The construction 'a',LF,'b' in J is similar to "a"+"\n"+"b" in languages where + works to append strings.

Ok, it makes sense than, thanks.

I was just reading the section on files from the 1962 APL book, and I think @AlliedEnvy is correct. This is how the data will appear to the program if read from a file in the question's format. The LFs represent partitions of the sequential file.

C# 540 399
Well, sacrificed performance (now it takes up to 30 seconds), introduced dynamic variables, slightly changed logic of solution. And yes, now it is expecting input as one string with line-breaks (as required in rules).
Of course C# do not have predefined math functions, so it would be hard to fight with Mathematica guys. Nevertheless, this was a great challenge, thanks to the author!
string S(string _){for(i=0,e=1>0;e;){
for(h=v=j=0;j<89;)m[j/10,j%10+9]=_[j++]-49;a="";
for(j=i++;j>0;v++,j/=2)if(j%2>0)F(v);
for(;h<9&(h<4|!e);h+=j/36,j%=36)if((e=m[h,g=j++%9+9]!=(t=(h+g)%9))|m[v=8-h,g]==t){F(v);F(g);F(v);F(g);}
}return a;}void F(int z){for(f=z<9;++l<9;)m[0,l]=m[f?z:l,f?9+l:z];for(;l-->0;)m[f?z:l,f?9+l:z]=m[0,8-l];a+=(char)(z+=f?49:56);}
dynamic h,v,i,j,e,t,l=-1,g,a,m=new int[9,19],f;

Test grids:
3B9A9A9B9B9C9C9D9D9F9F9G9G9H9H9I9I9B9B9C9C9D9D9F9F9G9G9H9H9C9C9D9D9C9C9D9D8B8B8F8F8H8H8B8B8F8F8B8B8H8H7B7B7C7C7F7F7H7H7I7I7H7H6A6A6B6B6C6C6D6D6F6F6H6H6A6A6B6B6D6D6F6F6D6D6D6D6F6F5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I

13AB9A9A9B9B9F9F9H9H9A9A9B9B9H9H9I9I8B8B8D8D8F8F8G8G8H8H8I8I8B8B8G8G8H8H8I8I8H8H7A7A7B7B7C7C7D7D7F7F7G7G7I7I7A7A7D7D7F7F7I7I7F7F6A6A6B6B6C6C6D6D6F6F6G6G6H6H6I6I6A6A6C6C6F6F6I6I6A6A6A6A5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I

2BC9A9A9C9C9D9D9F9F9A9A9D9D9I9I8B8B8D8D8H8H8I8I8B8B8D8D8I8I7B7B7C7C7D7D7F7F7G7G7H7H7I7I7C7C7C7C7G7G6A6A6B6B6D6D6F6F6G6G6I6I6A6A6B6B6D6D6G6G6D6D6F6F5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I5A5A5B5B5C5C5D5D5E5E5F5F5G5G5H5H5I5I

Old Solution (540)
Works in less than a second on any input (tested on thousands randomly generated grids). Maximum length of output string is 165 (initially any grid was solved in no more than 82 flips, but during golfing I sacrificed this).
string S(string[]_){for(i=0;i<1<<18;){
for(j=0;j<81;)m[j/9+49,j%9+65]=_[j/9][j++%9]-49;a="";char g,h='1',v='9',b,x=h,y;
for(j=i;j>0;x=x==v?'A':++x,j/=2)if(j%2>0)F(x);j=i+1;
for(i+=1<<19;h<58;h++,v--)for(g='A',b='I';g<74;g++,b--){
t=(h+g-6)%9;e=m[h,g];q=m[v,g];i=h>52&t!=e?j:i;
if(e!=t|q==t){x=q==t?v:g;y=q==t?g:v;
if(m[h,b]==t){x=b;y=h;}
F(x);F(y);F(x);F(y);}}}return a;}
void F(char z){var f=z<65;for(l=0;l<4;l++){n=m[d=f?z:49+l,s=f?65+l:z];m[d,s]=m[o=f?z:57-l,u=f?73-l:z];m[o,u]=n;}a+=z;}
int i,j,q,e,t,l,s,d,n,u,o;int[,]m=new int[99,99];string a;

Answer for example 1:
15A5A5B5B5C5C5D5DE5E55F5F5G5G5H5H5I5I

Answer for example 2:
19AI1I1H1H1G1G1F1F19F9F9G9G9H9H9I9I8A8AI8I87A7AI7I76A6AI6I65A5A5B5B5C5C5D
5DE5E55F5F5G5G5H5H5I5I

Answer for example 3:
129AI1I1H1H1G1G1F1F19F9F9G9G9H9H9I9I8A8AI8I87A7AI7I76A6AI6I65A5A5B5B5C5C5
D5DE5E55F5F5G5G5H5H5I5I

Answers for test squares:
346B9A9AH1H1C9C9D9D99F9F9G9GH9H99I9IB8B8F8F87B7B7C7C7F7FH7H77I7I6A6A6B6BC6C66D6DG6G6H6H66I6I5A5A5B5B5C5C5D5DE5E55F5F5G5G5H5H5I5I

1346ABA9A9H1H19F9FH9H99I9IH2H28D8D8F8FG8G8I8I8I3I37B7B7C7CF3F37G7GI7I7H4H4D6D66F6F5A5A5B5B5C5C5D5DE5E55F5F5G5G5H5H5I5I

2BCA9A99C9CF1F19F9F9I9IH2H2D8D88H8HI8I87B7BC7C77D7D7F7F7H7H7I7II4I4B6B6D6D6G6G66I6I5A5A5B5B5C5C5D5DE5E55F5F5G5G5H5H5I5I

I'm just downloading Mono for my Mac now so I can test the program itself, but I do already have a validator which runs a given solution on a given grid and tells me if the solution is a valid solution for that grid - and it's telling me that the three example solutions you've given me are not valid. I'm just investigating why now.

Aha! I've figured out what's happened here! Your given answers seem to be answers to the 3 examples and not the three test grids (which are lower down in the question). They are indeed correct solutions to those grids, though they are quite a bit longer than 1, A, and 2I which are the simplest solutions - but that doesn't actually matter since I'm not judging on grid solution length :-) If you could edit and give the answers for the 3 test grids (I'm going to see if I can get this running on my Mac now) I can give you your +1.

@Gareth - oops, I did missed answers for test squares, thanks for pointing that out. I have added them now to my answer.

Excellent, thanks for that. They've all validated fine. Xamarin wouldn't run on my Mac for some reason, so I'm going to have to test the program at work in a couple of hours.

@Gareth - Actually there is nothing specific for C# in that code, one can probably convert it to Java or even C++ without much pain and... golf some characters out of it :) Also feel free to convert it to GolfScript or something more concise - this may appear twice or more shorter ;)

I'm trying to run this on Visual C# express and it's giving me errors. I don't use this normally, so it's probably me at fault. I've just created a console project and pasted your code over the top of the default code that's given, then when I try to build it gives me errors. What am I missing?

@Gareth - You should place it inside class (named Program by default), create instance of this class inside Main method, and call my S function on instance of this class.

I've got it working now, thanks. There is a small issue in that your function expects an array of strings, whereas the input given in the specification is one string including line-breaks.

@Gareth - Thanks for pointing this out! Single line is more good in terms of golfing. But I'm curious about line breaks, do we really need them? They are different for different OS, should we assume Windows two-symbol \r\n ?

Assume \n for this question.

I really think we should disallow function declarations like this which aren’t valid complete programs... :/

@Timwi I allow for functions in the question, so it is a valid answer as long as it takes one string rather than an array of strings.