Harry Rose

Home » LOLCODE » NumberGuesser

Number Guesser

Well, it's finally happened. I've written a script in LOLCODE, the source isn't made any prettier by the lack of indents (thats because the interpreter I was using didn't like it). If you need to find an interpreter the one I used was this one running under wine.

HOW DUZ I GUESSNUMBERS
	
	I HAS A LOWVALUE ITZ 0
	I HAS A HIGHVALUE ITZ 1000
	
	VISIBLE "Think of a number between :{LOWVALUE} and :{HIGHVALUE}"
	
	I HAS A ISCORRECT ITZ FAIL
	
	IM IN YR GUESSLOOP UPPIN YR SOMECOUNTER TIL ISCORRECT
		I HAS A MIDVALUE ITZ QUOSHUNT OF DIFF OF HIGHVALUE AN LOWVALUE AN 2
		I HAS A GUESS ITZ SUM OF MIDVALUE AN LOWVALUE

		VISIBLE "Is it :{GUESS}? [Y(es)/H(igher)/L(ower)]"

		I HAS A RESPONSE
		GIMMEH RESPONSE

		VISIBLE "You said :{RESPONSE}"

		BOTH SAEM "Y" AN RESPONSE, O RLY?
		YA RLY
			VISIBLE "WIN"
			ISCORRECT R WIN
		OIC

		BOTH SAEM "H" AN RESPONSE, O RLY?
		YA RLY
			LOWVALUE R GUESS
		OIC

		BOTH SAEM "L" AN RESPONSE, O RLY?
		YA RLY
			HIGHVALUE R GUESS
		OIC

	IM OUTTA YR GUESSLOOP
IF U SAY SO

HAI
	GUESSNUMBERS
KTHXBYE

Output

Use and output is as follows (lol is the name of the interpreter I'm using).

harry@quanta ~ $ lol helloWorld.lol
Think of a number between 0 and 1000
Is it 500? [Y(es)/H(igher)/L(ower)]
L
You said L
Is it 250? [Y(es)/H(igher)/L(ower)]
L
You said L
Is it 125? [Y(es)/H(igher)/L(ower)]
H
You said H
Is it 187? [Y(es)/H(igher)/L(ower)]
L
You said L
Is it 156? [Y(es)/H(igher)/L(ower)]
L
You said L
Is it 140? [Y(es)/H(igher)/L(ower)]
H
You said H
Is it 148? [Y(es)/H(igher)/L(ower)]
H
You said H
Is it 152? [Y(es)/H(igher)/L(ower)]
L
You said L
Is it 150? [Y(es)/H(igher)/L(ower)]
Y
You said Y
WIN
Press ENTER to continue...