text:
Perfect Hangman in reverse
This is similar to other hang-man style problems already posted, except, in this case, the computer is the one guessing. Computers are logical, smart, and consider self-preservation to be important, so there are a few RULES for how computers will guess.
The user will think of any word, that will be contained in the FULL Ispell word list. some of these may be upwards of 10-15 letters. The wordlist is simply the full ispell wordlist (english, and others, all combined), and may be placed in a folder with the program.
The computer will be given 8 lives. The computer will start by simply asking for an input of however many characters the word is. (example game below). After that, the computer will begin guessing, following the ruleset below!

the computer will analyze all possible word outputs, and determine what letter guess has the most possible correct answers, and guess that letter. It will not duplicate any prior guesses.
the computer will then ask for an updated word input, determine if it was correct at all, or wrong, and if wrong, will deduct 1 life.
Lastly, the computer will state the lives remaining.
EXAMPLE GAME
User picks the word "Engineer"
Computer asks for Letter count, User replies 8.
Computer searches for most likely letter to be used in 8 letter words, determines it is letter H (not correct). Guesses H.
User replies _ _ _ _ _ _ _ _
Computer outputs "7 lives remaining" and then picks the next most likely letter, an E
User replies e _ _ _ _ e e _
computer outputs "7 lives remaining" and then recalculates based on its current knowledge what is the most likely next letter.
Game continues until computer will state WIN, or LOSE.

SCORING: every program should follow the EXACT same method to arrive at the final answer. If yours follows the order of every other program, you receive -100 points. If yours is different (aka wrong), you receive 1000 points.
each byte of code is worth 1 point. a 30 letter code, is 30 points.
if your code manages to play each step of the game in less than 5 seconds, award yourself -100 points.
The winner will be chosen 1 week from the first answer, and a new question related to this one, will be asked. Obviously those with the best code here will have a head start on the new one!
EDIT: forgot to make note that as in golf, the lowest score wins.

Will there be no spaces in the input?

I'm tempted to post code which does something completely unrelated to the task, while there are no other answers (and my program therefore works exactly the same as all programs!). "Different" is a ridiculous definition of "wrong", in particular if you don't give any proper reference to what's right.

@leftaroundabout the question states that the computer should guess the letter that has the "most possible correct answers" only in cases where multiple letter choices have exactly the same chance of being right should two programs ever differ. I don't know how often that will be though.

ispell list contains a lot of words ending with <'s>. Would these be acceptable words, or can we clean the wordlist, excluding the above mentioned words?

What if (assuming 4 answers) two people solve with method A and two with method B, does everyone get the +1000 penalty?

Also running time and "game steps" have a definition a bit too loose: running time on what machine? Is the time taken to ask the first input (word's length) considered as a step or could it take as long as needed and still be eligible for the 100 points deduction (as long as the other steps are completed in the 5 secs timeframe)?

Could we please have an example of expected output and input? (i.e. "7 lives remaining" or "7", "1 life remaining" or "1 lives remaining" is acceptable?)

Please can we have some clarification on the format of output strings (if they are mandatory). Obviously people actually printing the word "guess" have a longer program than those who are not.

Since alot of people decided to just use "guess" lets go ahead and make it the standard on this one. "X Lives Remaining" will be the other standard output string. and then either "WIN" or "LOSE" for the final output.
the 5 second rule just simply assumes that once given input, it completes that step of the process within 5 seconds on a reasonable machine (will be tested on an i7 930 2.9mhz 4xcore)
tiebreaks for the program in case of the same counts, simply have your program pick the one with the most possible words matching that guess, if still a tie, pick the one alphabetically first.

This contest will end in 1 week. August 3rd, at noon, CST.
at that time, the next step of the contest will be posted.

one other issue I am seeing, after an incorrect guess, your program should recount, removing all words with that letter from the calculations. a good example of where this would CHANGE the guesses would be a list of words such as (good, google, open, amp, ant) its first guess would be "o"(3 values), if incorrect, it should remove good, google, and open from the wordlist it is considering, resulting in the next guess of "a" - ant, amp, NOT a guess of g.

also, you should NOT prompt for the correct word before beginning. only the number of letters, and then the result after each word.

regarding tiebreaks, the above statement "tiebreaks for the program in case of the same counts, simply have your program pick the one with the most possible words matching that guess, if still a tie, pick the one alphabetically first." - can simply be read as "alphabetically first", as the first tiebreak is kinda the point of the program... Don't ask where I got it from >.>
in addition; words from the wordlist can assume to not include any symbols such as apostrophes etc, and it can be assumed that a word will be chosen from the list.

K, 196 215 240 (40 points)
When reduced to a single line it's 240 chars but I've added newlines here for readability. The question doesn't state exactly what the output needs to look like so I've come up with something fairly minimal.
r:0#t:#[c:#w:_0:0;"?"]
a:_:'0:`a;
l:8;
while[~(l=0)|(c=0);
  q:{x@&~x in y}[>#:'=,/a:a@&a like\:t;r];
  if[1=#a;-1 a;j:-1"WIN";exit 0];
  -1"Guess ",u:*q;
  r,:u;
  $[|/u=w;[c-:+/u=w;@[`t;&u=w;:;u]];-1($l-:1)," lives remaining"];
  -1 t;
  $[0=l;-1"LOSE";0=c;j;]]

The wordlist is a file called a in same directory as the code.
$ q hm.k -q
engineer
Guess e
e????ee?
Guess s
7 lives remaining
e????ee?
Guess i
e??i?ee?
engineer
WIN

EDIT: It now reanalyses the word on each step and determines which is the most likely letter based on previous guesses.
EDIT2: If there is only one possible answer (after reanalysis) the computer wins, rather than continuing to guess each individual letter

How come you didn't manage to get engineer correctly?

My code just cycles through the most popular characters for 8 letter words and guesses each in turn. I'm changing a few things now

I think the requirement is that after you lose a life, you re-analyse the possible words.

That's fixed now

just letting you know; I was a bit vague on tie-breaks for the algorithm in the description, please read the above comment on the question for a better idea. Basically tiebreaks should pick the alphabetically first.

Haskell, 781 - 100n
Takes the dictionary file name as command line argument.
Notices when you try to cheat.
words tested and able to beat this on my 90k English word dictionary: 'zappa' and quite a few words of form '.u..y', such as putty
It used to have nice prompts and more descriptive output but I ended up golfing those away.
It sanitizes dictionary file, filtering out words including non-alphabets and making it all lower case. Removing that would save me 48 bytes, but it's functionality I don't like to remove.
I believe this is fast enough for the -100, but I haven't tested it with anything bigger than that 90k words.
Also my first haskell program that really does something in IO. All comments welcome.
import System.Environment
import Data.List
import Data.Char
import Data.Ord
import qualified Data.Set as S
import Control.Monad
a=['a'..'z']
r=putStrLn
z=show
k=length
fb False=0
fb True=1
lp l=map fst.filter((==l).snd).zip[1..]
gu m@(g,p,t)l=fmap(\e->
 (l:g,S.filter((==e).lp l)p,t-(fb$null e)))$fmap(lp l)(putStrLn[l]>>getLine)
y m@(g,p,t)=case((S.size)p,t)of{(_,0)->r"I lost :<";(1,_)->r$'=':S.toList p!!0;
(0,_)->r"Cheater >:|";_->r(z t++" turns left.")>>
(gu m$fst.last.sortBy(comparing snd).filter(not.flip elem g.fst).zip a$
S.fold(zipWith(+).(\x->[fb$k`elem`x|k<-a]).nub.sort)(repeat 0)p)>>=y}
cg p=fmap(\h->([],S.filter((==(read h)).k)p,8))(r"Word length?">>getLine)
pd n=fmap(S.fromList.filter(all isAlpha).words.map toLower)(readFile n)
main=getArgs>>=pd.(!!0)>>=cg>>=y

Edit, 868 -> 830
Re-thought the input so I was able to golf away the unsafeIO which required not only a long function call but also an import. Took away the stupid prompt nobody has (for this reason I also updated my example run). Made one or two lambdas point-free, the only one remaining is the (\x->[fb$k`elem`x|k<-a]) which gets longer if made point free.
Edit, 830 -> 781
Huge thanks to leftaroundbout here. Removed some unnecessary dos, changed some returns to fmaps and unpacked tuples at binding. I guess I still didn't understand all his advice, but this already got me a long way forward. Unfortunately I had to include one space for indentation to keep my lines under 80 chars, since now I don't have those do blocks with ;s delimiting expressions.
Run with hangover
% ./reversehangman /usr/share/dict/british
Word length?
8
8 turns left.
e
______e_
8 turns left.
s
______e_
7 turns left.
d
______e_
6 turns left.
r
______er
6 turns left.
i
______er
5 turns left.
a
_a____er
5 turns left.
n
_an___er
5 turns left.
o
_an_o_er
5 turns left.
w
_an_o_er
=hangover

Yes, I fixed that. Thanks for letting me know, although I just noticed :X.

Great. I wasn't sure if putting comments as part of my answer was acceptable, but I felt I should try to get the information across somehow. I'm not a big fan of this "Sure you can answer, but you don't have the reputation to comment others' answers."

You should be able to get a lot of the program logic out of IO. Remember that Haskell is lazy! If you do use IO, always consider that, like every monad, it's also a functor. foo >>= return.bar is more compactly written fmap bar foo, and you usually don't need do{...} at all. — There are a couple of other things to improve, for instance tuples can be unpacked right in the function binding, e.g. y m@(g,p,t)=case(S.size p,t)of...: no need for let(g,p,t)=m in... there! — This fb looks rather suspicious, I don't think it's a good idea. Use guards instead of matching on booleans.

@leftaroundabout Wow, thanks! I'll definitely look into those later today. I should've at least understood to use m@(g,p,t). I think I don't need the do{...} in main since everything is bound, but how would you implement cg without it? fb is a newly written fromBool :: Integer. I think I need to be able to add or subtract 1 in some cases depending on whether some expression is true. Like newLives = oldLives - fb (null $ length newLetters)

Python (386 352 328 294 300 chars, 100 points)
This was fun to do. Produces an error to stop the program. When inputting please give your word in uppercase.
Put the Ispells word list in a file called "a", no file extensions.
import re
a=input()
l=8
b=open('a').read().upper()
c=0
L=map(chr,range(65,91))
while 1:
 E=max((b.count(i),i)for i in L)[1];L.remove(E);print E,'\n',l,"lives remaining";d=c;c=raw_input();l-=d==c;b=''.join(re.findall(c.replace('_','[%s]'%sum(L)),b))
 if len(b)==a:print"WIN",b;Z
 if l==0:print"LOSE";Z

Not sure if it is allowed to hardcode the length into the program, and not ask the user.

@Leigh: The line a=input() asks for the number of letters.

My mistake, sorry (not so hot with python). l=8 is lives, not length :)

@Leigh: It's ok, I find it hard to understand golfed code too :P

You can remove f=open('a') and open the file directly in the loop, save yourself 4 chars (5 including newlines).

You don't re-analyse correctly after an incorrect guess. You should remove all words that contain the incorrect letter to get an accurate count of the remaining possible letters.

@Leigh: Does b=''.join(re.findall(c.replace('_','[A-Z]'),b)) not work well enough? A fault with this challenge is that there's no test cases, so I can't test my program :X

There's cases where yours does better (since will continue to use letter weights including words that have an invalid letter in them), and there's cases where it does worse (since it's possible to guess letters that can't possibly exist in the word)

PHP - 367 431 402 367 321 312 bytes (-100 for flow, -100 for quick turns, 112 total)
Requires PHP 5.4 (short array syntax) and short open tags (saves 3 bytes!) which is on by default with PHP 5.4.
It takes the number of letters in the word as a command line argument.
Example command line php -d short_open_tag=1 golf.php 8
Submitted solution - 312 bytes on disk - there are some deliberate hard newlines in here for pretty output formatting.
<?foreach(file('l',2)as$w)$L[]=strlen($w)^$argv[1]?'':$w;for($l=8,$i=[];$l;){$s=$i+count_chars(join($L));arsort($s);$i[$g=key($s)]=0;$h=chr($g);echo"$h
";$r=count_chars($u=trim(fgets(STDIN)));$r[46]||die('WIN');$L=preg_replace($r[$g]||$l--<0?"/^((?!$u).)*$/i":"/.*$h.*/i",'',$L);echo"$l lives remaining
";}?>LOSE

Before fat-trimming, with some comments to explain what's going on
foreach(file('l',2)as$w) // Words from file called
    $L[]=strlen($w)^$argv[1]?'':$w; // Only words matching wordlen
for($l=8,$i=[];$l;){ // Loop, init lives + used guesses
    $s=$i+count_chars(join($L)); // Character frequency without guesses
    arsort($s); // Most frequent first
    $i[$g=key($s)]=0; // Guess is first item
    $h=chr($g); // Printable output
    echo"$h
"; // Literal newline saves us a byte
    $r=count_chars($u=trim(fgets(STDIN))); // User response
    $r[46]||die('WIN'); // short circuit win, and magic regex below
    $L=preg_replace($r[$g]||$l--<0 ? "/^((?!$u).)*$/i" : "/.*$h.*/i", '', $L);
    echo"$l lives remaining
";
} // End parsing because it's shorter than echoing
?>LOSE

Output with "engineer" - Spaces are not allowed, I'm using full stops instead of underscores due to uh... magic.
The program actually knows the word after 3 guesses, but continues 1 guess at a time anyway to save space.
e
e....ee.
8 lives remaining
s
e....ee.
7 lives remaining
n
en..nee.
7 lives remaining
i
en.inee.
7 lives remaining
g
enginee.
7 lives remaining
r
engineer
WIN

Variation using the same logic as beary605 - 269 bytes, -200 = 69 points.
<?$L=file('l',2);for($l=8,$i=[];$l;){$s=$i+count_chars(strtolower(join($L)));arsort($s);$i[$g=key($s)]=0;$h=chr($g);echo"$h
";$r=count_chars($u=trim(fgets(STDIN)));$r[46]||die('WIN');$r[$g]?$L=preg_replace("/^((?!$u).)*$/i",'',$L):$l--;echo"$l lives remaining
";}?>LOSE

There's some unaddressed comments about how strictly the output/user prompts needs to be, obviously I have taken liberties here as have other solutions.
Edits

Edit 1
Fatal logic error. I wasn't re-analysing correctly when the computer guessed correctly. This got me solving engineer with 5 lives remaining instead of 2, although at the expense of 64 bytes. I can probably improve this later.
Edit 2
Drastically improved matching by switching to a regex based filter. Also means I have to use full stops instead of underscores because the user input is essentially feeding regex patterns into the program.
Edit 3
Remembered to short-circuit evaluation to remove if statements, and use ternary operator to reduce 2 regex statements to 1.
Edit 4
Removed some verbosity with user prompting. Taking initial input on the command line. Removed an unnecessary staging variable. Removed case sensitivity.
Edit 5
Sacrificed efficiency for size, xoring word length with user supplied letter count to indicate inclusion. join is an alias of implode. Moved variable initialisation from outside the while loop to inside a for loop initiator saves me a byte!

eheh I was trying to solve this in a similar way, but I never really golfed before so my program was over 1KB. This answer will help me improve my golfing skills, although now probably there is no point posting my solution!! +1

btw, I think you could shave off one more byte removing the space after the php tag "<? $l=file('l',2);" becoming "<?$l=file('l',2);"

@milo5b: Thanks for the tip on the short tag, you can't do it on long tags and I never use short tags. (My first time golfing too). I've gone one better for saving space and improving logic at the same time by using regex to filter the words. Submit your answer anyway! It's fun!

There is no point in submitting it! It's using the same language and same logic as your script, but much worse implementation! I'll submit another challenge, or another language to this if I can find the time. And well done with all the improvements by the way

You can save two more bytes by removing <? at the start and invoke the code with the proper parameter.


text:
Shortest code that return SIGSEGV among the given languages
I come across a question in a coding competion
"write  a code that returns SIGSEGV(Segmentation fault )   " .
Points were given on the basis of length of code.
The prgramming languages available  were asm,c,c++,java .
I knew c language better  and submitted my code as
   main(){char *c="h";c[3]='j';}

But others solve it in shorter length  than me .  How it is possible ?  Can any one explain plz.
Platform UBUNTU 10.04

int main() { std::cout << "SIGSEGV(Segmentation fault )" << std::endl; }

but this is not shorter than above code!!

movl $0,0 (GNU AS syntax, x86_64 - the modern assembly segfault)

The question really can't be answered without reference to a specific platform. There is, for example, no C code that is guaranteed to give a SIGSEGV on every platform.

Hilarious, @sehe!

14 characters: main(){*""=0;}

@DietrichEpp, I'm afraid compiler may object without casting off const.

@sehe: That'd be both faster and shorter if you would do std::cout << "SIGSEGV(Segmentation fault )\n"; instead. :-)

@MichaelKrelin-hacker: Not in traditional C mode, with warnings turned off.

This is a question that has an answer. There is a shortest program that produces the desired result. I don't agree that it should've been closed.

I'd be pretty interested in ANY java (excluding JNI/A since that'd be C again) code that produces a sigsev ;)

This is a "make a list" question, and that is "not constructive" writ large.

@dmckee There's also an "explain it" component, which is perhaps somewhat redeeming.

The folks at nntp:comp.lang.c would have everyone know that using any declaration for main other that int main(void), void main(void), or int main(int,char**) is "implementation-defined", and therefore no longer standard C.

bending the rules a bit ; the C linker doesn't care if 'main' is a function or not :
int main=0;

indeed, the default type is 'int' and the default global initialiser is 0 :
main;

That's pretty darn short. +1 And it compiles (though with a warning)

+1: Though, if it were my question, that would be bending the rules too far for me to accept as an answer. But that's still really impressive, and likely about the shortest you can go.

In C, something like this is fairly short:
int main(void)
{
  return *(int *)0=1;
}

...or for a less proper version with minimal whitespace:
main(){*(int*)0=1;}

...even less proper, but shorter (the source code, at least):
main(){puts(0);}

It calls puts() with an implicit prototype, but still "works" if linked with the standard library.

There are many ways to make a program return SIGSEGV. One of these is via segmentation fault due to stack overflow of a recursive function calling itself a lot of times. In C, a short (if not the shortest) code for this would be:
main(){main();}

is there any shorter code than this in other language..?

In java, even the 'public static void main' is larger than this. Probably there's a shorter solution in asm, but I'm not really sure about it...

Besides may other ways of suicide as demonstrated by others, your way could be expressed a bit shorter as
main(){++*((int*)"");}

Assembly, 3 characters
RET

C, 5 characters
main;

Nah, as short as this :
int main;

As the accepted answer shows, you don't even need the int .

Ruby, 18 characters
I know this wasn't requested, but have a Ruby one, because why not. :D
Process.kill 11,$$

source: Stack Exchange

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

sort: votes


text:
Detecting loops in in in strings
Given a string, mark which parts in the string repeat in box brackets, and write how many times it does so before the box.
Example:st st st Hello ThereThere
st(with a space after) repeats 3 times, There repeats 2 times, and l repeats 2 times in Hello, so the output will be:
3[st ]He2[l]o 2[There]
There is no space between [st ] and Hello because the space in the string is being taken up by the repeating part. [st ], 3 times with a Hello after it would be st st st Hello, which is what the string has.
Other examples:
st Hello st st Bye -> st He2[l]o 2[st ]Bye
Bookkeeper -> B2[o]2[k]2[e]per
/\/\/\\\\\\\\/\/\/ -> 3[/\]6[\]3[\/]
Shortestest code wins.
EDIT: To clarify the choice of selections, choose the largest possible repeating section, and try and leave as little non-repeating characters as possible. Do not nest boxed-in sections.

This is ambiguous. For example, ababababcabcabc -> 4[ab]2[cab]c? 4[ab]c2[abc]? 3[ab]3[abc]? What bout abcdefdefghiabcdefdefghi -> 2[abcdefdefghi]? abc2[def]ghiabc2[def]ghi? 2[abc2[def]ghi]?

@Mechanicalsnail: I have elaborated in the recent edit. To answer your questions, ababababcabcabc -> 3[ab]3[abc], abcdefdefghiabcdefdefghi -> 2[abcdefdefghi].

this is not possible ;)  just the typical first answer I get whenever I ask a developer something.

@kinjal Then you aren't asking the questions the right way. Try to formulate your questions in the form of a coding challenge. So not "Can you do this?" but "Fastest solution wins!"

Shouldn't the output to your first example be "3[st ]He2[l]o 2[There]"? (Same for the second.)

@Howard: think of it as RLE for strings, i.e. the repeating strings need to be contiguous.

@PaulR That's what I said. We have two consecutive l inside Hello.

Why gets “st Hello st st Bye” transformed into “st Hello 2[st ]Bye” and not into “st Hello2[ st] Bye”? So the repeating substring why not starts with the first repeated character, the space before “st”?

@Howard: sorry - I missed the point there - you're right.

@Howard: Yes, it should be. I overlooked that. manatwork: Try not to have spaces before characters in repeating sequences.

The specification is still ambiguous because it lists multiple goals without clearly stating their relative priority, and without indicating what level of naïvety is acceptable. I don't see the point in constructing complicated test cases to elucidate the points: either the question needs to be largely rewritten to give precise acceptance criteria or it needs to be amended to indicate that wide latitude will be given.

Perl, 36 bytes
#!perl -p
s!(.+)\1+!@{[$&=~/\Q$1/g]}."[$1]"!eg

Try it online!

PHP 5.6, 68 bytes
Same code in PHP. Requires the command line option -F, and relies on deprecated /e modifier.
<?=preg_filter('/(.+)\1+/e','substr_count("\0","\1")."[\1]"',$argn);

C, 224 205 203 199 195 193 chars
The string is given as program parameter. As usual, use double quotes if your string contains spaces, and for empty strings - calling the program without any parameter crashes, but calling with "" works.
Output for test cases is:
st st st Hello ThereThere => 3[st ]He2[l]o 2[There]
Bookkeeper                => B2[o]2[k]2[e]per
/\/\/\\\\\\\\/\/\/        => 3[/\]2[\\\]3[\/]

which looks correct to me regarding "choose the largest possible repeating section".
Code:
l,r,f,i;char*c;main(a,b)char**b;{l=strlen(c=b[1]);for(;putchar(*c);c++)for(a=l;--a;f=0)for(r=a;!f;r+=a){for(i=0;i<a;)f|=r>l||c[i]-c[r+i++];if(f*r>a)c[a]=0,printf("\b%i[%s]",r/a,c),c+=r-1,a=1;}}

scala, 102 chars
print("(?!\\s)(.+)\\1+".r.replaceAllIn(readLine,m=>m.matched.size/m.group(1).size+"["+m.group(1)+"]"))

Output
st st st Hello ThereThere ->    3[st ]He2[l]o 2[There]
st Hello st st Bye        ->    st He2[l]o 2[st ]Bye
Bookkeeper                ->    B2[o]2[k]2[e]per
/\/\/\\\\\\\\/\/\/        ->    3[/\]2[\\\]3[\/]

+1, nice use of Regex.Match

Retina, 40 37 24 bytes
(.+)(\1)+
$.($#2*__)[$1]

-13 bytes thanks to @Neil.
Try it online or verify all test cases. (NOTE: Slightly different results for some test cases in comparison to the challenge description, but still the same as the accepted answer, so I assumed both are valid.)
Explanation:
(.+)(\1)+       # Look for the repeated sections (where the repeated string is captured in
                # group 1, and every time it's repeated in group 2)

Example: in the input "st st st Hello ThereThere" it will find the capture group 1 and 2 as: "st " & ["st ","st "]; "l" & ["l"]; and "There" & ["There"] respectively.
   $#2          # Get the amount of times group 2 was repeated
      *_        # Converted to unary (that amount of '_')
        _       # + 1 (with an additional '_' added)
$.(      )      # Convert that unary back to a number again by taking the length
          [$1]  # And append the match of the first capture group between block-quotes
                # after the number

Example: "st st st " will become "3[st ]"; "ll" will becomes "2[l]"; and "ThereThere" will become "2[There]". So "st st st Hello ThereThere" is now the intended result "3[st ]He2[l]o 2[There]" (which is output implicitly).

Perl 5 -p, 41 bytes
s|(.+)\1+|(length($&)/length$1)."[$1]"|ge

Try it online!

PowerShell, 82 bytes
[regex]::Replace($args,'(.+)\1+',{$a,$g=$args|% gr*
"$($a.Length/$g.Length)[$g]"})

Try it online!

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:
Calculate golden ratio
Write the shortest code, in number of bytes, to display, return, or evaluate to the golden ratio (that is, the positive root of the quadratic equation: \$x^2-x-1=0\$, approximately
1.618033988749895), to at least 15 significant figures. No input will be given to your program.
Sample in Stutsk programming language:
1 100 { 1 + 1 swp / } repeat print

This question will need a scoring criteria, input/output specification, etc. Please read the FAQ - http://codegolf.stackexchange.com/faq

@ardnew: I'll try to at least nail down an input (namely none) and winning criterion (shortest code). The expected output is, well...most languages support double-precision, so let's do that and call it good. :-)

Perl, Python - 10 chars
probably other languages too
.5+5**.5/2

That's also a nice entry for the polyglot challenge :) (http://codegolf.stackexchange.com/q/6764/3527)

.5+5^.5/2 will work in Octave/MATLAB, probably some others too

Julia 0.7, 2 bytes
φ

Try it online!
I'm surprised nobody has posted this yet...

That’s an old version of Julia! Does it not work in 1.5?

Julia 1.0+ moved a lot of stuff out of Base, often making the code much more verbose...

Why it's 2 bytes? I just see one character, does the tab include in length of program?

@AmirrezaRiahi Unlike golfing languages, Julia doesn't use a custom codepage, so this is scored in UTF-8, where greek letters use 2 bytes.

Mathematica 11
GoldenRatio

This is the irrational number itself, not an approximation of it.
Examples (first 2 examples from Mathematica documentation)
FullSimplify[GoldenRatio^4 - GoldenRatio]
FullSimplify[GoldenRatio^20 + 1/GoldenRatio^20]
FullSimplify[GoldenRatio^2 - GoldenRatio - 1]

3 + Sqrt[5]
15127
0

Desmos, 8 bytes
aa-a~1
a

Try it on Desmos!

Wait yo using regressions to get constants is actually so smart, you should post that as a tip on the Desmos code golfing tips page. I've always done it like this, which is 11 bytes.

PHP 17 chars
This one is just trolling, but hey.
1.618033988749895

k (10 chars)
As continued fraction:
{%x%x+1}/1

Or in closed form for 11:
%2%1+sqrt 5

J, 7 chars
-:1+%:5

some more text for the filter (my first J solution, heh)

When I run -:1+%:5, the result is 1.61803. Is something more needed in the program (or system settings) to get the required "at least 15 significant figures"?

@r.e.s the question asks " to display, return, or evaluate". It is evaluated to the correct precision, just not displayed. It's a compliant answer.

APL, 7
2÷⍨1+√5
÷2÷1+√5
.5×1+√5
.5+√5÷4

Curses! I can't find a way to do it in less than 7 characters! Dialect is Nars2000.

Dyalog APL: 1+∘÷⍣=1

JavaScript (ECMAScript), 10 chars
5**.5/2+.5

This is the same as the Perl & Python submission - thanks to Redwolf Programs for telling me about this.
However, back in 2012, when this answer was originally written, the ** operator did not exist in JavaScript. While almost all browsers and do now support the exponentiation operator, according to Can I Use, as of July 2020, around 9% of users still does not support it, including the latest version of Internet Explorer. Thus, the old version of the answer:
JavaScript (backwards-compatible), 17 chars
Math.sqrt(5)/2+.5

There's now a ** operator, so 5**.5/2+.5 would work too. Note that this is the same as the python submission.

Language Agnostic, 15 chars
9227465/5702887

If all you need is enough precision for an IEEE 32 bit float, you can do it in 9 chars:
6765/4181

This will only work for languages that don't treat integer division specially.

9227465/5702887 produces only 13 correct digits - it differs on 14. digit.

14930352/9227465 is probably the shortest, you can find it using optimal algorithm as advised on math.SE

dc, 8 chars
Fk5v1+2/

The value is on top of the stack - can be printed by adding p to the end of the program.
F pushes 15 on the stack (trick found here), k sets the precision to 15 digits. The rest is normal postfix notation :-) v is a square root. Trailing p for print was omitted.

It can be argued that the p is not needed, because the requirement is to evaluate (not necessarily display) to 15 places.

@r.e.s. interesting bending of rules :) thanks, updated :)

J, 10 9 8 chars
p.1,1,_1

(root of polynomial: -x^2+x+1)
>:@%^:_+1

(continued fraction (9 chars))
%:@>:^:_+1

(continued root: (10 chars))

05AB1E, 6 bytes
5X‚t;O

Try it online!
Explanation
5      Push 5
 X     Push 1
  ‚    Pair: [5, 1]
   t   Square root: [2.23606797749979, 1.0]
    ;  Halve: [1.118033988749895, 0.5]
     O Sum: 1.618033988749895

Arn, 3 bytes
phi

Just a builtin, too short to be compressed. Returns 1.61803398874989484820458683436563811.
A more interesting one. If running in the downloadable version, this will print n digits, given the command:
arn run file.arn -p n

or 25 digits if the -p flag is not provided.
If running in the online version, this will print the first 50 digits.
6 bytes
l[├Qn0

Try it!
Explanation
Unpacked: :-1+:/5
:-       Halve
    1    Literal one
  +      Plus
    :/   Square root of
      5  Literal five

arn has no increment command?

The increment command is two bytes, ++. This increments variables too, which gives it a unique purpose.

Husk, 4 bytes
(floating-point; accurate to 15 significant figures)
½→√5

Try it online!
This seems (to me) to be surprisingly readable for a golfing language...
  √5    # square root of 5
 →      # increment
½       # halve

Husk, 9 bytes
(calculation as arbitrary precision rational number)
!Ẋ/İf!5İ⁰

Try it online! (TIO header converts the rational number [expressed in Husk as a fraction] to its first 1000 decimal digits)
  /         # get the ratio of
 Ẋ          # every pair of elements of
   İf       # the fibonacci sequence;
!           # now select the ratio at position
     !5İ⁰   # 10^5 (change to !9İ⁰ for more accuracy with same byte-count)

Malbolge, 102 bytes
(C%;_#!7[}{3Wyw/St,+0/(-&Jlk"FEg|{A?~,`<^:r[Y64m3kT0Rg,xwc;J`&%#5"!~Bji.-,X;POsMppn"2GFEiCg+e?>b<;_#![

Try it online!

brainf, 93 bytes
+++++++[>+++++++<-]>.---.++++++++.-----.+++++++.--------.+++..++++++.-..-.---.+++++.-.+.----.

Try it online!
It works :/
Not very optimised though. I can’t think of any way to optimize this, although I’m sure a way exists.
Explanation:
+++++++         Add seven to cell at 0.
[               Begin a loop.
     >+++++++   Add seven to cell at 1.
     <          Go back to cell 0.
     -          Decrement the counter there (soon it will reach 0).
]               End loop when cell 0 reaches 0 after 7 repetitions.
>               Go to cell 1 which is now 49.
.               Print it (1).
---.            Decrement 3 to get 46 (period) then print it.

Afterwards, not much explanation is needed. Just add some
or subtract some and repeat until everything is printed.
++++++++.-----.+++++++.--------.+++..++++++.-..-.---.+++++.-.+.----.

K (ngn/k), 8 bytes
(1+1%)/1

Try it online!
Adapted from the built-in docs.

(...)/1 set up a converge-reduce, seeded with 1 and run until two successive iterations return the same result

(1+1%) add one to the inverse of the current value, and feed that into the next iteration

Ruby - 14 chars
(5**0.5)/2+0.5

Based on the Javascript Perl answer above.

Better base it on the Perl answer instead, 5**0.5 is shorter than Math.sqrt(5).

My mind was skipping on me, as I could not recall what the exponential equivalent to sqrt was....

8 years late... the parentheses are not needed.

Almost language agnostic, 9 chars
(tested in R):
.5+5^.5/2

In R, evaluates full double precision. More digits can be seen by setting options(digits=99). The question says "evaluate", so that goes with the rules.

Excel, 10 chars just prepend an = sign before this.

x86 machine code, 13 bytes
Hexdump:
b1 7f d9 e8 d9 e8 de c1 d9 fa e2 f8 c3

Disassembly:
100139D0 B1 7F                mov         cl,7Fh
100139D2 D9 E8                fld1
    again:
100139D4 D9 E8                fld1
100139D6 DE C1                faddp       st(1),st
100139D8 D9 FA                fsqrt
100139DA E2 F8                loop        again (100139D4h)
100139DC C3                   ret

Uses the converging sequence an = sqrt(an-1 + 1).
The number of iterations is determined by the contents of ecx, which is mostly garbage. The minimal number of iterations is 127, which guarantees good precision (actually, 30 iterations should be enough). In the worst case, the calculation will take a few minutes (232-1 iterations), and in the best case, it's instantaneous (127 iterations).

Python 3, 11 bytes
(1+5**.5)/2

= 1.618033988749895

Welcome to the site!

Whispers v3, 16 bytes
> φ
>> Output 1

Try it online!

><>, 29, 25 bytes
Saved 4 bytes!
After posting this answer I noticed the example Stutsk program and realized that I could probably save a few bytes. My new answer is based off the example given in the question. This program works because the golden ration can be expressed as a continued fraction.
golden_ratio = 1+1/(1+1/(1+1/...))
ff*101.;n~<
$1$,1+$:?!^1-

Try it online!
Old Answer
f201.;n,2+1~<
$:5$,+2,$:?!^1-

The second line approximates the sqrt of 5. After looping 15 times, this value is used to calculate the golden ratio.
Try it online!

Pyth, 3 bytes
.n3

Try it online!
11 bytes without builtin:
+c@5 2 2 .5

Try it online!

dc - 11 chars
15k5v2/.5+p

The most character-consuming task is setting the decimal precision..

Mathematica - 31
N[x/.Solve[x^2-x-1==0][[2]],16]

1.618033988749895

(It's going to be the longest code, I expect...:)

Japt, 2 bytes
MQ

Test it
Or 6 bytes without the built-in:
½+5¬/2

Test it

#  (commonmark migration)

MathGolf, 1 byte
φ

Builtins ftw ¯\_(ツ)_/¯
Try it online.
Without builtins it's 6 bytes:
51α√½Σ

Try it online.
Explanation:
φ       # Push golden ratio builtin 1.618033988749895
        # (output the entire stack joined together implicitly as result)

5       # Push 5
 1      # Push 1
  α     # Wrap the last two values into a list: [5,1]
   √    # Take the square-root of each value: [2.23606797749979,1.0]
    ½   # Halve each: [1.118033988749895,0.5]
     Σ  # And sum this list: 1.618033988749895
        # (after which the entire stack joined together is output implicitly as result)

CJam, 7 bytes
X5mq+2/

Try it online
Just one more byte than 05AB1E! Pretty simple stack-based translation of the equation on the Wikipedia page:
X5         Push 1 and 5 on to the stack
  mq       Square root the top number
    +      Add the top two numbers on the stack
     2/    Divide by two
           (implicit) output the stack

I've removed the non-competing tag as that no longer exists, but otherwise, nice first answer! Be sure to check out our tips for golfing in CJam as well, and hope you enjoy it here!

@caird Thanks! I've read old Code Golf threads for a while and I've seen that a few times, so I figured it was required. Thanks for the tips, I'm glad to finally try participating!

MUMPS, 11 bytes
w 5**.5+1/2

Output: 1.618033988749894849
This highlights a quick about MUMPS: order of operations is evaluated left to right. Something like .5+5**.5/2 would give us (5.5**.5)/2 (1.172603939955857389).

05AB1E, 4 bytes
5t>;

Try it online!
5t>;  # full program
   ;  # divide...
 t    # square root of...
5     # literal...
  >   # plus 1...
   ;  # by 2
      # implicit output

Gol><>, 4 bytes
S1n;

This answer feels like cheating because S1 simply pushes the golden ratio onto the stack.
This answer doesn't work with TIO, but it does work with this interpreter: Try it online!

Tcl, 23 bytes
puts [expr (1+5**.5)/2]

Try it online!

Pip, 6 bytes
URT5/2

Replit! Or, here's a 7-byte equivalent in Pip Classic: Try it online!
Explanation
 RT5    Square root of 5
U       Increment
    /2  Divide by 2

Factor + math.unicode, 4 bytes
φ .

Try it online!

Rattle, 8 bytes
=5e.5+/p

Try it Online!
Explanation
=5          set top of stack to 5
  e.5       square root
     +      increment
      /     divide by 2
       p    print value

This first approach is pretty boring, it's just a direct calculation. Here's a slightly more exciting 13-byte method which calculates many Fibonacci numbers then finds the ratio between them:
+s[+~$]99$/~p

Try it Online!
Explanation
+s              increment the top of the stack (to 1) and save to memory
  [   ]99       loop 99 times
   +~           increment top of stack by the value in memory
     $          swap the top of the stack for the value in memory
         $      swap the top of the stack for the value in memory
          /~    divide the top of the stack by the value in memory
            p   print value

Vyxal ḋ, 2 bytes
kg

Try it Online!

Python, 33 bytes
ratio=(1+5**(1/2))/2
print(ratio)

Output:
1.618033988749895

Welcome to the site! You should indicate in your answer which language this is, as well as the byte count. Furthermore, I've edited your answer slightly to improve the formatting. Could you also edit in a link to a site where users can test your code, such as Try It Online!? Hope you enjoy it here at CGCC!

(1+5**(1/2))/2 is by itself is a snippet so wouldn't be a valid answer, and ratio=(1+5**(1/2))/2<newline>print(ratio) is sufficiently long it may not be a serious contender for the winning criteria of the challenge.

22 bytes, making it a serious submission

@Lyxal 19 bytes

C (gcc), 37 bytes
Very basic solution, calculates exact value & prints.
main(){printf("%.15f",.5+sqrt(5)/2);}

Try it online!

Jelly, 2 bytes
Øp

Try it online!

POSIX bc, 13+2(?)=15(?) bytes
bc forbids non-integer exponents, so:
.5+sqrt(5/4)

(incl. the newline) plus -l for the math library (which also conveniently bumps the scale); therefore:
$ echo '.5+sqrt(5)/2' | bc -l
1.61803398874989484820

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


text:
Find top student from three test marks
First save the following text into a file called marks.csv
Smith,6,9,24
Jones,9,12,20
Fred,5,9,20

Each line contains a students name and three marks they scored. Find the top student by simply summing the three marks and then output their name. In this case the output is:
Jones

I would like to see somebody beat my Python solution but any language will be allowed :) If anybody beats my Python solution I will accept their answer but for now I will just accept the shortest code.

K, 37
m[0;*>+/1_m:("SIII";",")0:`marks.csv]

Cat (5 characters)
Jones

You don't specify that the code has to work on other datasets as well ;-)
Save code in a file FILE and execute with:
cat FILE

Doesn't follow the requirement: Find the top student by simply summing the three marks *and then* output their name

Don't you see the part right before the word Jones? It does all the calculations.

In this case implies other input is possible. -1

Mathematica, 44
SortBy[Tr/@Import@"marks.csv",First][[-1,2]]

If I were allowed to save the data in Mathematica's native format in a file named z I could use:
SortBy[Tr/@<<z,First][[-1,2]]

Your answer appears to be problematic. Try running: Tr /@ Import@"marks.csv". I get {"{6, 9, 24}" + "Smith", "{9, 12, 20}" + "Jones", "{5, 9, 20}" + "Fred"} as output.

@David I think your file is in the wrong format.  It should contain exactly the text shown in the first code block in the question.

Would you kindly show me the exact code you are using for exporting the file in the first place.  Somehow, my integer lists are interpreted as strings.

@David I didn't Export the file; I used Notepad and pasted the text from the question into it.

Ruby 1.9 (71 62)
$><<open('marks.csv').max_by{|l|eval l[/,.*/].tr ?,,?+}[/\w+/]

PHP, 103 95
I know PHP is not the best tool for this problem, however I would appreciate any tip to improve my answer :)
First version (103)
<?$h=fopen('marks.csv','r');for(;$f=fgetcsv($h);$m[$f[0]]=array_sum($f));echo array_search(max($m),$m);

Improved version, inspired by @Leigh's solution (95) - considering low error level:
<?$h=fopen('marks.csv',r);for(;$f=fgetcsv($h);$m[array_sum($f)]=$f[0]);ksort($m);echo end($m);

Easier to read version:
<?
$h=fopen('marks.csv',r);
for(; $f=fgetcsv($h); $m[$f[0]]=array_sum($f));
echo array_search(max($m),$m);

Thanks

I was just about to post a new solution based on yours ;) - Except I had moved the fopen into the first part of the for loop. FYI I started the results array the same as yours, with arsort + key. Then I reversed the results and used ksort + end. Every little helps :)

PHP, 97 93
Original
foreach(file('marks.csv')as$l){$x=str_getcsv($l);$r[array_sum($x)]=$x[0];}ksort($r);echo end($r);

Inspired by milo5b
for($f=fopen('marks.csv','r');$l=fgetcsv($f);)$r[array_sum($l)]=$l[0];ksort($r);echo end($r);

And how to run without tags.
cat golf.php | php -a

You would also need starting <? php tag. And by the way, you inspired an improvement to my solution, thanks eheh +1

Don't need the tags, and thanks to you too ;)

eheh great I did not know this. I will not edit my solution further or we'll end up with exactly the same code!

btw i think you forgot to take off the string quotes around 'r' in fopen

I'll let you keep that one, or we'll end up with the same code ;)

You should add two bytes for the '-a' switch :P

Mathematica 59 49 53 chars
Sort[{Tr@Rest@#, #[[1]]} & /@ Import@"marks.csv"][[-1, 2]]

Because csv is a subject to various interpretations, I'm including the exact file contents of o.csv:
{{"Smith", 6, 9, 24}, {"Jones", 9, 12, 20}, {"Fred", 5, 9, 20}}

I missed the filename requirement, which is now taken into account.

fix taken into account ;-) +1

@Mr.Wizard It turns out that % will work as the file name, provided that it is executed right after exporting the file.

I like your ambition, but honestly I don't think that's fair: the export becomes part of your program.

I rolled back to an earlier version for another reason. I seem to have been getting the right answer for the wrong reason.

JavaScript (Node.js), 146 134 133 bytes
(feedback welcome)
s=a=>eval(a.split`,`.slice`1`.join`+`);_=>(""+require("fs").readFileSync("marks.csv")).split`
`.sort((a,b)=>s(b)-s(a))[0].split`,`[0]

Try it online!

Python, 82
print max((sum(eval(m)),n)for n,m in(l.split(',',1)for l in open("marks.csv")))[1]

Awk, 64
$ awk -F, '{s=$2+$3+$4;if(s>m){m=s;n=$1}}END{print n}' marks.csv

{s=$2+$3+$4}s>m{m=s;n=$1}END{print n} is shorter - 30 chars

R, 58
j=read.csv("marks.csv",F);j[which.max(rowSums(j[,2:4])),1]

Alternatively (62 characters):
j=read.csv("marks.csv",F);j[which.max(apply(j[,2:4],1,sum)),1]

k (47 chars)
Allows for ties
(*x)'&(|/i)=i:+/'+:1_x:("SIII";",")0:`marks.csv

This might be orthodox and first of it kind on Code golf. Below will work find under circumstances where CSV file - been imported into as a table ( External Table) on Oracle.
M := Marks.csv Table
a-d := CSV Fields
PLSQL 60 Characters
SELECT a,max(b+c+d) FROM M WHERE ROWNUM<=1 GROUP BY a,b,c,d;

C# Two different versions
Version:1 245 Characters
using System;using System.Linq;namespace X{class Y{static void Main(){Console.Write((from l in System.IO.File.ReadAllLines("m.csv")let x =l.Split(',')select new{f=x[0],a=x.Skip(1).Sum(Z=>Int32.Parse(Z))}).OrderByDescending(p=>p.a).First().f);}}}

Version:2 214 Characters
using System;using System.Linq;namespace X{class Y{static void Main(){Console.Write(System.IO.File.ReadAllLines("m.csv").OrderByDescending(z=>z.Split(',').Skip(1).Sum(y=>Int32.Parse(y))).First().Split(',')[0]);}}}


text:
Self-matching regex
Write a non-trivial regex that matches itself.
For example, #.*$ will match a comment outside of a string in python until the end-of-line, and also matches itself in perl regex syntax.
Rules:

The regular expression must do something useful or practical.
Tell what regex syntax you are using (e.g. perl or POSIX).
Winner is the highest voted compliant answer.
Be creative!

There was a question on SO a while ago, whether there is a regex that matches valid regexes: http://stackoverflow.com/questions/172303/is-there-a-regular-expression-to-detect-a-valid-regular-expression

@padde Very interesting! :)  In the comments, they said that regex doesn't match itself, but it apparently matches all non-recursive regex.  Too bad--that would likely be a winning entry (matching itself and all other entries).

Define non-trivial. I mean, OK, A would be trivial, but where do you draw the line? And by "self-matching" do you mean it can only match itself, or is it allowed to match other strings too? Would . qualify?

@MrLister Non-trivial would be decided by voters.  Self-matching means that it matches itself, but part of it being useful/practical means that it matches other things too.  . qualifies as a self-matching regex, but that's also pretty trivial.  So is ABC123Hello World.

@padde which actually wasn't a regex because the grammar that describes regular expression is context-free.

@FUZxxl yes, that is true but one could still write a regex that matches other regexes, but doesnt care about the validity of the matched regexes.

@padde Well, what is an invalid regex then? An invalid regex obviously isn't a regex. So you essentially say: "yes, that is true but one could still write a regex that matches other regexes, but doesnt care if the matched regex really is a regex" (sic!)

@FUZxxl, "regex" and "regular expression" parted ways many years ago. Now the relationships between them are i) an inclusion; and ii) an etymological link.

What does the winner get?

/.+/ Matches itself and can be used to determine if a string is empty or not.

/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g

Stolen from https://github.com/LeaVerou/prism/blob/gh-pages/components/prism-javascript.js. This should match (in JavaScript) all JavaScript regular expressions.

PYTHON
Below is a self-matching regex generator. You provide two lists, one contains training data that the regex should match (in addition to matching itself), the other contains training data the the regex should NOT match:
from random import choice, randrange
import re
from itertools import zip_longest, chain, islice
from operator import itemgetter

CHAR_SET = [chr(i) for i in range(128)] + [r"\\", r"\d", r"\D",
                                           r"\w", r"\W", r"\s",
                                           r"\S", r"?:", r"\1",
                                           r"\2", r"\A", r"\b",
                                           r"\B", r"\Z", r"\.",
                                           r"\[", r"\]", r"\(",
                                           r"\)", r"\{", r"\}",
                                           r"\+", r"\|", r"\?",
                                           r"\*"]

CHAR_SAMPLE = []
BREAKPOINT = re.compile(
    r"""
    \(.*?\)|
    \[.*?\]|
    \{.*?\}|
    \w+(?=[\(\[\{])?|
    \S+?|
    \.\*\??|
    \.\+\??|
    \.\?\??|
    \\.|
    .*?
    """,
    re.VERBOSE)

MATCH_BRACKETS = {'(': ')', '[': ']', '{': '}'}
CLOSE_BRACKETS = {')', ']', '}'}
REGEX_SEEDER = [
    r".*?",
    r"(?:.*?)",
    r"\w|\s",
    r"(?<.*?)",
    r"(?=.*?)",
    r"(?!.*?)",
    r"(?<=.*?)",
    r"(?<!.*?)",
    ]

LEN_LIMIT = 100

def distribute(distribution):
    global CHAR_SAMPLE
    for item in CHAR_SET:
        if item in distribution:
            CHAR_SAMPLE.extend([item] * distribution[item])
        else:
            CHAR_SAMPLE.append(item)

def rand_index(seq, stop=None):
    if stop is None:
        stop = len(seq)
    try:
        return randrange(0, stop)
    except ValueError:
        return 0

def rand_slice(seq):
    try:
        start = randrange(0, len(seq))
        stop = randrange(start, len(seq))
        return slice(start, stop)
    except ValueError:
        return slice(0,  0)

#Mutation Functions

def replace(seq):
    seq[rand_index(seq)] = choice(CHAR_SAMPLE)

def delete(seq):
    del seq[rand_index(seq)]

def insert(seq):
    seq.insert(rand_index(seq, len(seq) + 1), choice(CHAR_SAMPLE))

def duplicate(seq):
    source = rand_slice(seq)
    seq[source.stop: source.stop] = seq[source]

def swap(seq):
    if len(seq) < 2: return
    a = rand_index(seq, len(seq) - 1)
    seq[a], seq[a + 1] = seq[a + 1], seq[a]

dummy = lambda seq: None

MUTATE = (
    replace,
    delete,
    insert,
    duplicate,
    swap,
    dummy,
    dummy,
    )

def repair_brackets(seq):
    """Attempts to lower the percentage of invalid regexes by
    matching orphaned brackets"""

    p_stack, new_seq = [], []
    for item in seq:
        if item in MATCH_BRACKETS:
            p_stack.append(item)
        elif item in CLOSE_BRACKETS:
            while p_stack and MATCH_BRACKETS[p_stack[-1]] != item:
                new_seq.append(MATCH_BRACKETS[p_stack[-1]])
                p_stack.pop()
            if not p_stack:
                continue
            else:
                p_stack.pop()
        new_seq.append(item)
    while p_stack:
        new_seq.append(MATCH_BRACKETS[p_stack.pop()])
    return new_seq

def compress(seq):
    new_seq = [seq[0]]
    last_match = seq[0]
    repeat = 1
    for item in islice(seq, 1, len(seq)):
        if item == last_match:
            repeat += 1
        else:
            if repeat > 1:
                new_seq.extend(list("{{{0}}}".format(repeat)))
            new_seq.append(item)
            last_match = item
            repeat = 1
    else:
        if repeat > 1:
            new_seq.extend(list("{{{0}}}".format(repeat)))
    return new_seq

def mutate(seq):
    """Random in-place mutation of sequence"""
    if len(seq) > LEN_LIMIT:
        seq[:] = seq[:LEN_LIMIT]
    c = choice(MUTATE)
    c(seq)

def crossover(seqA, seqB):
    """Recombination of two sequences at optimal breakpoints
    along each regex strand"""

    bpA = [item.start() for item in BREAKPOINT.finditer(''.join(seqA))]
    bpB = [item.start() for item in BREAKPOINT.finditer(''.join(seqA))]
    slObjA = (slice(*item) for item in zip(bpA, bpA[1:]))
    slObjB = (slice(*item) for item in zip(bpB, bpB[1:]))
    slices = zip_longest(
        (seqA[item] for item in slObjA),
        (seqB[item] for item in slObjB),
        fillvalue=[]
        )
    recombinant = (choice(item) for item in slices)
    return list(chain.from_iterable(recombinant))

#Fitness testing

def match_percentage(match):
    """Calculates the percentage a text actually matched
    by a regular expression"""

    if match and match.endpos:
        return (match.end() - match.start()) / match.endpos
    else:
        return 0.001

def fitness_test(seq, pos_matches, neg_matches):
    """Scoring algorithm to determine regex fitness"""

    try:
        self_str = ''.join(seq)
        regex = re.compile(self_str)
    except (re.error, IndexError):
        seq[:] = repair_brackets(seq)
        try:
            self_str = ''.join(seq)
            regex = re.compile(self_str)
        except (re.error, IndexError):
            return 0.001

    pos_score = sum(match_percentage(regex.search(item))
                    for item in pos_matches) / len(pos_matches) / 3

    neg_score = (1 - sum(match_percentage(regex.search(item))
                    for item in neg_matches) / len(neg_matches)) / 3

    self_score = match_percentage(regex.search(self_str)) / 3

    return pos_score + self_score + neg_score

#Population Management

def generate_pop(pos_matches, neg_matches, pop_size):
    sources = (pos_matches, REGEX_SEEDER)
    return [crossover(
        choice(choice(sources)), choice(choice(sources))
        ) for i in range(pop_size)]

def glean_pop(population, cutoff, fit_test, ft_args=()):
    scores = (fit_test(bug, *ft_args) for bug in population)
    ranked = sorted(zip(population, scores), key=itemgetter(1), reverse=True)
    maxItem = ranked[0]
    new_pop = next(zip(*ranked))[:cutoff]
    return maxItem, new_pop

def repopulate(population, pop_size):
    cutoff = len(population)
    for i in range(pop_size // cutoff):
        population.extend([crossover(choice(population), choice(population))
                           for i in range(cutoff)])
    population.extend([population[i][:] for i in range(pop_size - len(population))])

#Simulator
def simulate(pos_matches, neg_matches, pop_size=50, cutoff=10, threshold=1.0):
    population = generate_pop(pos_matches, neg_matches, pop_size)
    while True:
        for bug in population:
            mutate(bug)

        #Scoring step
        max_item, population = glean_pop(
            population,
            cutoff,
            fitness_test,
            (pos_matches, neg_matches)
            )

        #Exit condition:
        max_regex, max_score = max_item
        if max_score >= threshold:
            return max_score, max_regex
        """
        print(max_score, ''.join(max_regex))
        input("next?")"""

        #Repopulation Step:
        population = list(population)
        repopulate(population, pop_size)

Is this Python?

Why isn't the no_match_list (or but_not_these) variable used in the code?  Is this for python 2.7?

@Darthfett: Those are just usage examples.

@Griffin: Yes. It's Python 27. I'm editing my post to indicate that.

@JoelCornett Writing my own simulate function is part of the usage?  Your simulate function doesn't use argument #2.

@Darthfett: No that is an example of how you would call the function. I used variable names that were descriptive of their (hypothetical) contents. My mistake about parameter 2, it was a typo. no_match is supposed to be renamed no_match_list. Edited

Why do you call population = generate_pop(pos_matches, neg_matches, pop_size), but the generate_pop function never makes use of the neg_matches parameter? Also, can you please include an example of calling the function? Could I call it like simulate(["Hello","World","world"], ["woah","bad","dont match"])?

Hey, it's been a few years since I wrote this. Just reading over the code without testing, it appears that yes, you can call the simulate() function as you described. And yes, you are right: I don't use the negative data for generating the initial population.

JavaScript regular expression that matches stuff like it.
/^\/\^\\\/\\\^[\\\[\]\/\^\${},\dd]{34}$/

You can test it like so:
(function test() {
    var re =/^\/\^\\\/\\\^[\\\[\]\/\^\${},\dd]{34}$/;
    var m  =/=([^;]+)/.exec(test)[1];
    return re.exec(m);
})();

What is "stuff like it"?  Is this practical or useful in any way?

@Darthfett: It matches similar regular expressions that attempt to match themselves and this regular expression. No, it's not practical or useful in any way, but the only possible practical or useful, but also interesting, regular expression that matches itself is a regular expression to match regular expressions. Which has been done.


text:
Generate the names of the keys on a piano
On a standard 88 key piano, each key has a scientific name.
The first three keys are A0, B♭0, and B0. The keys then proceed through C1, D♭1, D1, E♭1, E1, F1, G♭1, G1, A♭1, A1, B♭1, B1, and start over again at C2. This continues up through B7, and the final key is C8.
Any flat can instead be written as a sharp of the preceding note, e.g. D♭4 can also be written C♯4. If necessary, you can write "D♭4" as "Db4".
Your program should build an ordered sequence (array, list, vector, etc.) containing the key names (as strings, symbols, or some similar data structure) in order.
Program length should be measured in characters, to avoid penalizing people who properly generate ♯ or ♭ rather than # or b. However, Unicode recoding is forbidden.

Here is a previous question that might be useful, as it involves taking note names as input.

"Unicode recoding is forbidden." Can you edit the question to explain what that means, please?

I'd prefer having scoring by bytes, except in the case of ♯ and ♭ which count as one byte each.

@Chris: I think it may refer to putting a compressed byte sequence into a Unicode string and just decompressing that.

Bash shell script (58)
echo {8..0}{B,♭B,A,♭A,G,♭G,F,E,♭E,D,♭D,C}|rev|cut -b40-410

If you do not have rev, you can instead use tac -rs. at a cost of five characters.
Bending the rules, I can subtract thirteen characters (for a score of 45):
echo {8..0}{B,♭B,A,♭A,G,♭G,F,E,♭E,D,♭D,C}|rev

If you really need a bash array, add six characters to the score (for a score of 64):
a=(`echo {8..0}{B,♭B,A,♭A,G,♭G,F,E,♭E,D,♭D,C}|rev|cut -b40-410`)

Can you say more about tac -rs?  In GNU coreutils 8.23 (and 6.10), tac -rs (the same as tac --regex --separator) complains about -s missing an argument, and tac -rs "" says it cannot be empty.  I don't see a BSD version of tac (though BSD does have rev) to compare to.

GolfScript, 60 57 characters
"A BbB C DbD EbE F GbG Ab"88,{1$2<@2>1$+\{8%},@9+12/+}%\;

The snippet produces the following array (see here):
["A0" "Bb0" "B0" "C1" "Db1" "D1" "Eb1" "E1" "F1" "Gb1" "G1" "Ab1"
"A1" "Bb1" "B1" "C2" "Db2" "D2" "Eb2" "E2" "F2" "Gb2" "G2" "Ab2"
"A2" "Bb2" "B2" "C3" "Db3" "D3" "Eb3" "E3" "F3" "Gb3" "G3" "Ab3"
"A3" "Bb3" "B3" "C4" "Db4" "D4" "Eb4" "E4" "F4" "Gb4" "G4" "Ab4"
"A4" "Bb4" "B4" "C5" "Db5" "D5" "Eb5" "E5" "F5" "Gb5" "G5" "Ab5"
"A5" "Bb5" "B5" "C6" "Db6" "D6" "Eb6" "E6" "F6" "Gb6" "G6" "Ab6"
"A6" "Bb6" "B6" "C7" "Db7" "D7" "Eb7" "E7" "F7" "Gb7" "G7" "Ab7"
"A7" "Bb7" "B7" "C8"]

Edit: Changed from " "/""* to {8%}, to remove space.

I'm kind of intrigued by GolfScript, but a bit confused.  Do you know of any tutorials that would help a beginner learn the language?  I've tried the tutorial on the official GolfScript web site and looked at several other pages retrieved on Google, but it doesn't make a whole lot of sense.

@MikeDtrick There are some Golfscript answers on this website that have explanations about how they work (e.g.  http://codegolf.stackexchange.com/a/6058/3527). However, the best way to learn GS is to start coding something. Even better - try submitting a GS answer and you'll learn from the feedback you'll get :)

@MikeDtrick other commented examples: http://codegolf.stackexchange.com/a/166/3527, http://codegolf.stackexchange.com/a/172/3527

@w0lf Thank you for the resources!

@w0lf I know this probably isn't the proper place to ask a question, but I'm trying to code an answer for this question in GolfScript.  I have a work in progress for the question, but I wanted to get in touch with someone who is skilled in this area.  This is just practice, I won't post the answer if someone helps me out.  Sorry for being a pest.

@MikeDtrick I can't say I'm skilled, but I want to help you if I can. I've created a chat room for this: http://chat.stackexchange.com/rooms/4361/discussion-between-w0lf-and-mike-dtrick

Mathematica 95 112 100 97 104 chars
Admittedly not very streamlined:
Take[Flatten@Table[# <> ToString@k & /@
Partition[Characters[" CDb DEb E FGb GAb ABb B"], 2], {k, 0, 8}], {10, 97}]

The Flat symbol, although it occupies a single character, is transcribed to SO as \[Flat] so I used the letter "b" here.
Output:

Length@%
(* out *)
88

How do you count 95 chars?

I forgot to change the character count when I made a correction. It is now correct. (White spaces are there for legibility only, with the exception of those between quotes.)

I get 100 keys from this rather than 88, but I can't find a rule against that, so +1 :-)

Weird. I too had noticed the 100 keys, but couldn't find an error.

David, your comment made me look at this again.  The output is no longer agreeing with the picture you included.  It starts "A0", "Bb0", " B0", " C0", and furthermore "C1" doesn't occur until after "Db1", " D1"` etc. (Previously I thought the real keys were in order and there were extras interspersed.)  Sorry, but it's broken. :-(

You are right once again.  And here I was happy, thinking I had broken 100 chars.

Python 103 96 94 78
[x+y for y in'0123456789'for x in'C Db D Eb E F Gb G Ab A Bb B'.split()][9:97]

updated according to Ev_genus's suggestion
updated according to Howard's suggestion

94 [x+y for y in'0123456789'for x in['C','Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B']][9:97]

Maybe you can use 'C Db D Eb E F Gb G Ab A Bb B'.split()?

omg, really! 78 [x+y for y in'0123456789'for x in'C Db D Eb E F Gb G Ab A Bb B'.split()][9:97]

@Howard yeah, i forgot about that

Ruby: 75 71 characters
[*?0..?9].product(%w{C Db D Eb E F Gb G Ab A Bb B}).map{|a,b|b+a}[9,88]

(Base idea borrowed from Matt's solution.)

You can use [*?0..?9] which is a little shorter.

I felt that I am missing something there, but I completely forgot the splat. Thank you @Howard.

J, 81 76 63 62 61 58 characters
_11}.9}.(_2]\,|:9#"0'C DbD EbE F GbG AbA BbB '),.12#1":i.9

Output:
A 0
Bb0
B 0
C 1
Db1
D 1
Eb1
E 1
...
G 7
Ab7
A 7
Bb7
B 7
C 8

Probably a bit of room for shortening here.

C (92 84 characters)
Not impressive, could be reduced further.
main(i){for(i=9;printf("%c%c%d\n","CDDEEFGGAABB"[i%12]," b b  b b b "[i%12],i/12),++i<97;);}

Using Dietrich Epp's suggestion :
main(i){for(i=9;printf("%.2s%d\n","C DbD EbE F GbG AbA BbB "+2*i%24,i/12),++i<97;);}

It produces the following output :
A 0
Bb0
B 0
C 1
Db1
D 1
Eb1
E 1
F 1
Gb1

... // lines skipped

Eb7
E 7
F 7
Gb7
G 7
Ab7
A 7
Bb7
B 7
C 8

Can shave off 6 characters: main(i){for(i=9;printf("%.2s%d\n","C DbD EbE F GbG AbA BbB "+(i%12)*2,i/12),++i<97;);}

@DietrichEpp: Thanks! I shaved off two other characters.

Mathematica, 88
88 characters for 88 keys :-)
(Row@{#2,#1}&@@@Tuples@{0~Range~8,StringSplit@"C D♭ D E♭ E F G♭ G A♭ A B♭ B"})[[10;;97]]

C, 105 chars
- failing on size, so ended up aiming for a wtf different solution.
Probably only works on little-endian arch (e.g. intel) due to assumptions of treating int as small string...
Assumes C program is called with no arguments, i.e. that w=1
t=12352,f;
main(w){
  t=t&64?t>>8:(w=1+w%7,(w-3)%3?t<<8|98:t+(w==3));
  f=t<<8|w+64;
  puts(&f);
  f-14403?main(w):0;
}

Output:
A0
Bb0
B0
C1
Db1
D1
Eb1
E1
F1
Gb1
G1
Ab1
--lines skipped--
Bb7
B7
C8

Edits

-9 chars - removing some brackets and reorganising an 'if'
-18 chars - code shuffling, sub 64 from w and pass as main arg
-13 chars - Use 't' to carry state rather than 'f'

Really creative answer!

Clojure - 71 chars
(for[c(range 10)n["C""Db""D""Eb""E""F""Gb""G""Ab""A""Bb""B"]](str n c))

Haskell: 72 chars
take 88$drop 9[p++show o|o<-[0..],p<-words$"C D♭ D E♭ F F♯ G G♯ A B♭ B"]

Perl, 57+1
Just dug this up, a nice golfing exercise.  Requires -E for say -- counted in score.
say+(CDbDEbEFGbGAbABbB=~/(.b?)/g)[$_%12],$_/12%9for 9..96

JavaScript (Node.js), 88 bytes
(o=`C,Db,D,Eb,E,F,Gb,G,Ab,A,Bb,B`.split`,`)=>o.flatMap((x,i)=>o.map(n=>n+i)).slice(9,97)

Try it online!


text:
Use a genetic algorithm to recreate a string
AKA: the most complex way to return a string I could think of.
Requirements:
*Edit: * @Griffin, You are correct, the goal is to use crossover/mutation of characters in a string to eventually come up with the same as input, although, "Hello World" was simply an example. Really, I just like to see what the others on the site can come up with.
Golf. Try to keep it short.
Have fun, dag nabbit!
Preferences (not required):
-Using a fixed seed on a random number generator would help others reproduce your results.
-Bonus if you test for 'properties' of the string, such as the number of L's in "Hello World", instead of only correct characters (like mine).
Shortest code, or highest voted, wins.
One exception: if you manage to create a working version in BrainF***, you win.
My take using Java:
import static java.lang.Math.*;import java.util.Arrays;import static java.lang.System.out;import java.util.Random;class G{static char[]c;static Random r;public static void main(String[]a){c=a[0].toCharArray();r=new Random(6);P w=new P(9);int n=0;while(!w.f){w.s();if(w.f)out.println(w.g[w.p].x()+"@gen "+n);n++;}}static class P{boolean f=false;int p=0;M[]g=null;P(int s){if(s>=9)g=new M[s];else g=new M[9];for(int i=0;i<g.length;i++)g[i]=new M(c.length);}void s(){f();if(!f){h();j();}}void f(){for(int i=0;i<g.length;i++){g[i].f(c);if(g[i].l==0){f=true;p=i;}}}void h(){Arrays.sort(g);}void j(){M[]b=new M[g.length];for(int i=0;i<g.length-1;i++){float k=r.nextInt(100);if(k<40)b[i]=new M(g[0],g[1]);else if((k<60)&&(k>40))b[i]=new M(g[0],g[2]);else if((k<80)&&(k>60))b[i]=new M(g[1],g[2]);else if((k<90)&&(k>80))b[i]=new M(g[2],g[3]);else if((k<95)&&(k>90))b[i]=new M(g[2],g[4]);else if((k<99)&&(k>95))b[i]=new M(g[0],g[r.nextInt(g.length)]);else b[i]=new M(g[0],new M(c.length));b[g.length-1]=g[0];}g=b;}}static class M implements Comparable {char[]a=null;int l=0;int q=0;int u=8;int o=20;public int compareTo(Object o){M t=(M)o;if(this.l<t.l)return-1;else if(this.l>t.l)return 1;return 0;}M(int s){a=new char[s];for(int i=0;i<a.length;i++)a[i]=(char)r.nextInt(255);}M(M m,M p){a=new char[m.a.length];for(int i=0;i<m.a.length;i++){a[i]=(r.nextInt(100)>2)?m.a[i]:p.a[i];int z=r.nextInt(100);if(z<u)a[i]=(char)r.nextInt(255);else if(z<o){int b=r.nextInt(6);a[i]=(char)(a[i]^(1<<b));}}}void f(char[]v){l=0;for(int i=0;i<a.length;i++){int d=abs(a[i]-v[i]);l+=d;}}String x(){return new String(a);}}}

Example output from my code:
Hello World!@gen 3352

Could you clarify the challenge a bit please? I'm assuming we are to create a genetic algorithm which starts off with a random string and produces the string Hello World! through iterative random mutation/recombination of the start string.  Is this correct?

APL (98)
L←⍴T←⎕UCS'Hello World!'⋄F←{+/2*⍨⍵-T}⋄0{0=F ⍵:⍺,⎕UCS⍵⋄(⍺+1)∇{(F⍵)≤F⊢C←⍵+(2-?3)×(⍳L)=?⍴⍵:⍵⋄C}⍵}L?255

Can be shortened, at the expense of easy configurability and of result, I'll do so when this one is beaten.
Output:
5940 Hello World!

(or another number between ~4000-~9000).

Credit for the algorithm: http://www.electricmonk.nl/log/2011/09/28/evolutionary-algorithm-evolving-hello-world/
Explanation:

L←⍴T←⎕UCS'Hello World!': The target is the ASCII values (⎕UCS) of 'Hello World'. (You can change the string.) L is its length.
F←{+/2*⍨⍵-T}: F measures the 'distance' between a candidate and a target. This is the sum of the squares of the difference between each character.
0{0=F ⍵:⍺,⎕UCS⍵⋄(⍺+1)∇...⍵}L?255: Starting with a random string (L?255), if the distance between the target and the candidate is 0 (i.e. we have it) (0=F ⍵:), then output the generation and the string (⍺,⎕UCS⍵). Otherwise, mutate the candidate and proceed to the next generation.
(F⍵)≤F⊢C←⍵+(2-?3)×(⍳L)=?⍴⍵:⍵⋄C: Generate a new candidate by selecting a random position and mutating it by one. If the distance to the target is less than the old candidate, return the new candidate, otherwise keep the old candidate.

pdfTeX, 2663
\RequirePackage{xparse}
\ExplSyntaxOn
\tl_new:N \l_my_base_tl
\int_new:N \l_my_len_int
\prop_new:N \l_my_base_prop
\prop_new:N \l_my_trial_a_prop
\prop_new:N \l_my_trial_b_prop
\int_new:N \l_my_diff_a_int
\int_new:N \l_my_diff_b_int
\cs_generate_variant:Nn \tl_replace_all:Nnn { Nno }
\DeclareDocumentCommand{\do}{v}
  {
    \tl_set:Nx \l_my_base_tl { \tl_to_str:n {#1} }
    \tl_replace_all:Nno \l_my_base_tl { ~ } { \c_catcode_other_space_tl }
    \int_zero:N \l_my_len_int
    \tl_map_inline:Nn \l_my_base_tl
      {
        \int_incr:N \l_my_len_int
        \prop_put:NVn \l_my_base_prop \l_my_len_int {##1}
      }
    \my_get_diff:NN \l_my_base_prop \l_tmpa_int
    \int_step_inline:nnnn { 1 } { 1 } { \l_my_len_int }
      { \prop_put:Nnn \l_my_trial_a_prop {##1} { O } }
    \my_term:
    \my_get_diff:NN \l_my_trial_a_prop \l_my_diff_a_int
    \bool_set_false:N \l_tmpa_bool
    \bool_until_do:Nn \l_tmpa_bool
      {
        \prop_set_eq:NN \l_my_trial_b_prop \l_my_trial_a_prop
        \prop_map_inline:Nn \l_my_trial_b_prop
          {
            \prop_get:NnN \l_my_trial_b_prop {##1} \l_tmpa_tl
            \prop_get:NnN \l_my_base_prop {##1} \l_tmpb_tl
            \exp_args:Noo \token_if_eq_charcode:NNF \l_tmpa_tl \l_tmpb_tl
              {
                \int_set:Nn \l_tmpa_int
                  { \exp_after:wN `\l_tmpa_tl + \pdfuniformdeviate 7 - 3 }
                \char_set_lccode:nn { `* }
                  { \int_max:nn { 32 } { \int_min:nn { 127 } { \l_tmpa_int } } }
                \tl_to_lowercase:n
                  { \prop_put:Nnn \l_my_trial_b_prop {##1} { * } }
              }
          }
        \my_get_diff:NN \l_my_trial_b_prop \l_my_diff_b_int
        \int_compare:nT { \l_my_diff_b_int < \l_my_diff_a_int }
          {
            \prop_set_eq:NN \l_my_trial_a_prop \l_my_trial_b_prop
            \int_set_eq:NN \l_my_diff_a_int \l_my_diff_b_int
            \int_compare:nT { \l_my_diff_b_int = 0 }
              { \bool_set_true:N \l_tmpa_bool }
            \my_term:
          }
      }
    \tex_end:D
  }
\cs_new_protected:Npn \my_get_diff:NN #1#2
  {
    \int_zero:N #2
    \prop_map_inline:Nn #1
      {
        \prop_get:NnN \l_my_base_prop {##1} \l_tmpa_tl
        \int_add:Nn #2
          {
            ( \my_char_value:o \l_tmpa_tl - \my_char_value:n {##2} )
            * ( \my_char_value:o \l_tmpa_tl - \my_char_value:n {##2} )
          }
      }
  }
\cs_new:Npn \my_char_value:n #1 { \int_eval:n { `#1 } }
\cs_generate_variant:Nn \my_char_value:n { o }
\cs_new_protected_nopar:Npn \my_term:
  { \iow_term:x { \prop_map_function:NN \l_my_trial_a_prop \use_ii:nn } }
\ExplSyntaxOff
\expandafter\do\noexpand

Call as
pdflatex Experiment573.tex +Hello, World+

where the + delimiters are arbitrary (identical).  I chose + here because many more conventional delimiters have a meaning on the command line.  This could be shortened quite a bit: I initially thought I'd need floating point computations, which are not available without the expl3 programming language, so I loaded and used that, which is quite verbose.

 Python, 289 286
from random import randint as r
s=map(ord,raw_input()[:-1])
L=len(s)
d=lambda x:sum((a-b)**2 for a,b in zip(x,s))
p=map(list,[(64,)*L]*500)
n=0
while 1:
 n+=1
 for b in p:b[r(0,L-1)]+=r(-5,5)
 if any(i==s for i in p):break
 p=sorted(p,key=d)[:100]
 p+=[i[:]for i in p][:500-100]
print n

Starting population is a list of strings: "@" * length_of_input. Uses the squared sum of the distance for each character and corresponding target character as the fitness function.

C# - 432
using System;using System.Linq;class M{static void Main(string[] a){var g=a[0];int l=g.Length,P=182,S=P/2,k=0,I=0;var r=new Random();Func<int,string>z=null;z=A=>A==0?"":(char)(r.Next(S)+32)+z(A-1);var p=new string[P];while(k<P)p[k++]=z(l);while(p[k=0]!=g){p=p.OrderBy(s=>s.Select((t,i)=>t==g[i]?0:1).Sum()).ToArray();I++;while(k<S){var Q=p[k].ToCharArray();Q[r.Next(l)]=z(1)[0];p[S+k++]=new string(Q);}}Console.WriteLine(I+" "+g);}}

Example output:
171 Hello there :)
Better formatted (character count is higher...)
using System;
using System.Linq;
class M
{
    static void Main (string[] a)
    {
        var g = a [0];
        int l = g.Length, P = 182, S = P / 2, k = 0, I = 0;
        var r = new Random ();
        Func<int,string> z = null;
        z = A => A == 0 ? "" : (char)(r.Next (S) + 32) + z (A - 1);
        var p = new string[P];
        while (k<P)
            p [k++] = z (l);
        while (p[k=0]!=g) {
            p = p.OrderBy (s => s.Select ((t,i) => t == g [i] ? 0 : 1).Sum ()). ToArray ();
            I++;
            while (k<S) {
                var Q = p [k].ToCharArray ();
                Q [r.Next (l)] = z (1) [0];
                p [S + k++] = new string (Q);
            }
        }
        Console.WriteLine (I + " " + g);
    }
}

Initialization
An array of 198 random candidates is created (by use of the recursive random string generation function z)
Main Loop
The array is (re)sorted by the number of mismatches within the string (this used less characters than power or absolute value). The bottom half of the population is replaced with mutations (by one char) on the first half (the fitter part of the population).
Termination
Once the fittest member is equal to the goal, the number of iterations is printed along with the output string.
This is my first golf submission and likely the last one done with C#. I may also try to regolf this in a terser language later.


text:
Random with your hands tied
Task
Develop some code to generate a psuedo-random number between X and Y (taken as input). Explain why or how it works.
Conditions

Do not use any random generating seeds, pre-written randoms, or external source to generate the random number.
Make something as close to random as you can get. No hard coding of values.

Whoever gets the most upvotes for a new, innovative, out of the box, idea, wins.

Are we supposed to generate a seemingly random number (or sequence of numbers) that can still be the same every time run, or do we need to get different numbers for each run. For the latter we positively need some source of an external seed that differs for each time run, which might be time or a file we've written to on our last run.

Is this a golf or a challenge ? The question says golf but the tag says challenge ?

what is meant by an external source?

@ardnew: Probably means that the program should run by itself, no webpages or files are referenced.

What exactly constitutes a "random number seed"? Any constant, noise, or any other value that is used to generate any other number can be a "seed", Can you be more precise in your definition? Also, how pseudorandom must the generator be?

its a challenge, highest upvotes win. the random should be some way of doing it unique, and should change every time. Ultimately top votes win, so just have some fun with it and think outside of the box.

alot of confusion on "external source" - the intent was that you couldn't use anything that is designed for random generation. As an example, time -could- be used, BUT its not really that original...
You just can't call random.org, or use something that basically does the job for you.

@NRGdallas: Thanks. That cleared it up a lot.

"Most votes" is not an objective winning criterion in the meaning of the FAQ. The winner should be obvious to a person examining the entries. Otherwise we have a simple popularity contest.

7 answers to a question that is apparently "not a real question". This site has so many negative people on it. Why does everything have to be objective? Photography competitions are subjective; is there not some art to solving many of these problems?

The SO asked the readers to judge submitted routines for a pseudo random number generator, taking into account the degree to which the proposals demonstrate original, "out of the box" thinking.   This is admittedly subjective, but fully reasonable as a code challenge.   The question is real.  It is not ambiguous, vague, incomplete or rhetorical.  It can be reasonably answered, as several submissions already made clear.  It should not have been closed.

@Griffin: Photography contests that allow public voting (as opposed to being voted on by an expert panel) are just as bad, as far as being a popularity contest goes. (I come from the view that popularity contests are content-free noise, and if you've seen the popularity contests that were all the rage back in the early days of Stack Overflow, you'll know what I'm talking about.) Next thing you know, people will want to post boat-programming questions here. Just say no.

@DavidCarraher: If you prefer, I'll be quite happy to choose a different close reason. The one I tend to use for "subjective winning criteria" questions is "off-topic". This is a matter of site policy: if you disagree with the policy, please make a post on meta where this can be discussed (although in the specific regard of the objectivity requirement, I believe this has been discussed multiple times before...).

@ChrisJester-Young:  I took your  reason for closing the question at face value as a sincere claim.  Apparently, you do not care what reason you give once you decide to close a question.  By the way,  reputations on Stack Exchange are officially based on the judgment of the community about the worth of contributions, so it's not as if this criterion were foreign to the enterprise.

@NRGdallas: If it's a challenge then please edit the word "golf" out of the question to avoid further confusion

@DavidCarraher: (Apologies in advance if I misread your comment.) The list of close reasons is standard across the Stack Exchange network. There isn't a special close reason called "too subjective" just for this site; instead, it straddles the line between NARQ, Not Constructive, and Off-Topic. So you have to choose one. On reflection, Not Constructive is probably a better close reason than Off-Topic. But my point remains: questions that are not even the slightest bit objective are not generally a good fit for this site. The lack of a close reason tailored for that doesn't contradict my point.

C
not sure if the volatile keyword is needed (or what other OS dependencies are assumed here)
simply takes the address of a variable, and maps it to [min, max]:
int rand(int min, int max)
{
  volatile int order = max - min + 1;
  return min + (int)&order % order;
}

this uses rand(
generally the goal of this was to avoid using such tools

@NRGdallas uses rand? are you talking about what i named the subroutine? this solution uses no library routines.

This is a relatively clever way of getting one random number, so I hardly call it an rng. Due to data alignment the code (at least on my machine) will output only even numbers. I get almost only negative numbers, since the address of order is high enough to be seen as a negative in and in C(++) the %-operator takes its sign from the dividend. Still the most innovative. +1

Perl
First, here is a solution that was golfed, coming in at 30 characters:
$a=<>;$b=<>;print$$%($b-$a)+$a

This solution uses the process number of the program as the random seed, similar to using the location of the variables as a seed. It works the best when the min and max are small compared to the process number.
Here is a version that uses command line arguments, with 36 chars:
 print$$%($ARGV[1]-$ARGV[0])+$ARGV[0]

And here is a version as a subroutine that returns the random value (without printing to screen), with 29 chars:
 sub a{$$%($_[1]-$_[0])+$_[0]}

Second, I am working on a solution that adheres to the strictest reading of the spec, which is that the program cannot be influenced by anything except the two arguments.

I don't know Perl syntax very well, but couldn't you declare $ARGV as another, shorter, variable?  Or just the value of $ARGV[0] to save a few characters?

The array @ARGV is how the command line arguments are read. By removing them, I would have to take the input a different way.

Actually, it appears that by taking input from STDIN, while causing me to add $a=<>;$b=<>;, actually saved me characters.

Mathematica
Rationale
Pi is an irrational number. It decimal representation does not repeat.
I strongly suspect that it does not "favor" any of the base ten digits,  0...9, nor any numbers of length when one partitions the decimal into strings of d digits.  This suspicion  can later be informally checked using the code below.
Code
The following will select integers between the integers x and y, where x is less than y.
y need not have the same number digits as x.   The routine will begin at the cth digit of Pi.  At the end of the procedure, the counter will be at c + n.
ClearAll[f]
f[x_,y_,c_,n_]:=
  Module[{diff=y-x,d},
  d=Length[IntegerDigits[diff]];
  Cases[FromDigits/@Most[IntegerDigits[Round[N[Pi,c+n+1]10^(c+n-1)]]][[c;;c+n1]]~Partition~d,
  i_/; i>x-1 && i<y+1]]

Suppose we want to generate a large (> 3000000), pseudo-random list of integers between 7 and
78.  Here is how to request it.  I've estimated that we'll need to use about 10^7 digits of Pi.  We'll begin from position 1, that is, c=1.
(results= f[7,78,1, 10^7])//Timing

Note how the unsorted and untallied results maintain the order of Pi's digits: 314159...
Note also that the result took just under 20 seconds.  As we move further along, we'll encounter practical limits to how much we can process in a reasonable amount of time. But since this is merely an exercise in thinking out of the box, we'll ignore this limitation as we proceed.
Examining the results
When we tally and plot the results we see that Pi does not particularly favor any numbers in this range:
SortBy[Tally[results],First]

Notice that the integers between 7 and 78 were chosen more or less with equanimity.  Further tests would show this holds up.
ListPlot[%]

Similar checks should show whether or not Pi plays favorites with any numbers at all, regardless of how many digits it holds.  [I checked for 1, 2, and 3 digit numbers over tens of millions of draws and found no bias starting from the beginning of Pi.  A rigorous check would require more systematic examination or theoretical insights.]

Python
import sha
R=lambda x,y:x+int(sha.new('%d_%d'%(x,y)).hexdigest(),16)%(y-x)

Gives you the same output if you provide the same x and y.

@MrZander:  the way I interpret the spec, that is inevitable.

Hardly "innovative", why not just multiply it by the time or something like that?

@MrZander because time is external source. If you can use time then just take microseconds since boot and map it to the given range.

Maybe I am interpreting it differently.  I see "external source to generate the random" as an external source designed for random number generation.  Up for interpretation, I guess.

JavaScript
function getRandom(x,y) {
    s=document.createElement("SCRIPT");
    s.src="http://search.twitter.com/search.json?q=%22random%22&&callback=t"
    document.getElementsByTagName("HEAD")[0].appendChild(s);
    var c = 0;
    window.t=function (d) {
        g=d.results;
        for(z=0; z<g.length; z++) {
            c+=g[z].id/0xfff;
        }
        console.log(x+c%(y-x))
    };
}

This is pretty disgusting really. Queries Twitter, via the JASONP API, for recent tweets containing the word "random", then it uses the ID's of each of the returned tweets to calculate the "random" number.
You might want to wait a few seconds in between each call of the function, also it doesn't return a value, it just outputs one to the console. (Told you it was disgusting).
You can try it here.

Nice idea, but without using ANY [...] external source.

using twitter API, I actually think its pretty creative. Read the above comment on the post for "any external source" it has been clarified to also show this is OK :)

@NRGdallas, thanks for clarifying. That's what I thought you meant by external source.

Python 2.x, 454
z=lambda n,b:int("0b"+(bin(n)[2:][:-b]or'0'),2)
r=range
g=624
def m(s,t):
 a=[s]
 for i in r(1,g): a+=[1812433253*((a[i-1]^(a[i-1]>>30))+i)]
 for i in r(t):
    i%=g
    if not i:
        q=0
        for c,d in zip(a,a[1:]+[a[0]]):
            u=(z(c,1)+z(d%g,31))
            a[q]=a[(q+397)%g]^(u>>1)
            if u%2:a[q]^=2567483615
            q+=1
    y=a[i]^(a[i]>>11)
    y^=(y<<7&2636928640)
    y^=(y<<15&4022730752)
    y^=(y>>18)
    yield y

Mersenne twister algorithm. It can probably be golfed some more.
Usage:
>>> list(m(s, t))

Where s is the seed, and t is the number of numbers to generate.

Unfortunately your hands are much more tied: without using ANY random generating seeds

Do you mean "without using any external seed"? If I set seed to a constant value, for example, would that satisfy the terms of the challenge?

I guess that wouldn't be random then, but a constant. That's the challeng (though I'm not the challenge author, so feel free to ask him in comments.)

Python, 32
Similar to ardnew's answer:
a,b=input()
print a+id(1)%(b-a)