Page 1 of 1

Pseudo Infinite Monkey Theorem

Posted: Tue May 03, 2011 9:35 pm
by Nituvious
I know this is stupid, but it was exciting to get "Hello" in 210k passes!

Code: Select all

Global Dim Letters.s(36)

#NO_PUNCTUATION			= 0
#SIMPLE_PUNCTUATION		= 1
#COMPLETE_PUNCTUATION	= 2
#NO_NUMERICAL				= 3
#NO_NUMERICALPUNCTUATION = 4

Define.l IMT_Type = #NO_NUMERICALPUNCTUATION
Define.s stringToMake.s = "Hello World!"
Select IMT_Type ;{ What kind of monkey do you have?
	Case #NO_PUNCTUATION
		For n = 97 To 122
			Letters.s(z) = Chr(n)
			z + 1
		Next n
		Letters.s(26) = Space(1)
		Letters.s(27) = "1"
		Letters.s(28) = "2"
		Letters.s(29) = "3"
		Letters.s(30) = "4"
		Letters.s(31) = "5"
		Letters.s(32) = "6"
		Letters.s(33) = "7"
		Letters.s(34) = "8"
		Letters.s(35) = "9"
		Letters.s(36) = "0"

	Case #SIMPLE_PUNCTUATION
		ReDim Letters.s(40)
		For n = 97 To 122
			Letters.s(z) = Chr(n)
			z + 1
		Next n
		Letters.s(26) = Space(1)
		Letters.s(27) = "1"
		Letters.s(28) = "2"
		Letters.s(29) = "3"
		Letters.s(30) = "4"
		Letters.s(31) = "5"
		Letters.s(32) = "6"
		Letters.s(33) = "7"
		Letters.s(34) = "8"
		Letters.s(35) = "9"
		Letters.s(36) = "0"
		Letters.s(37) = "."
		Letters.s(38) = ","
		Letters.s(39) = "?"
		Letters.s(40) = "!"

	Case #COMPLETE_PUNCTUATION
		ReDim Letters.s(94)
		For n = 33 To 126
			Letters.s(z) = Chr(n)
			z + 1
		Next n
		Letters.s(94) = Space(1)

	Case #NO_NUMERICAL
		ReDim Letters.s(30)
		For n = 97 To 122
			Letters.s(z) = Chr(n)
			z + 1
		Next n
		Letters.s(26) = Space(1)
		Letters.s(27) = ","
		Letters.s(28) = "."
		Letters.s(29) = "?"
		Letters.s(30) = "!"

	Case #NO_NUMERICALPUNCTUATION
		ReDim Letters.s(26)
		For n = 97 To 122
			Letters.s(z) = Chr(n)
			z + 1
		Next n
		Letters.s(26) = Space(1)

EndSelect ;}


OpenConsole() : ConsoleTitle("Pseudo-Infinite Monkey Theorem")

sTimer = ElapsedMilliseconds()
While UCase(stringToMake.s) <> UCase(formedString.s)
	count.l + 1 : formedString.s = ""
	For s = 0 To Len(stringToMake.s) - 1
		formedString.s + Letters(Random(ArraySize(Letters())))
	Next s
	PrintN(Str(count) + ": " + formedString.s)
Wend
eTimer = ElapsedMilliseconds() - sTimer
PrintN(#LF$ + "Finished creating the sentence in " + Str(count.l) + " attempts. It took " + Str(eTimer/1000) + " seconds.")
Input()

Re: Pseudo Infinite Monkey Theorem

Posted: Tue May 03, 2011 10:08 pm
by Rook Zimbabwe
It took my machine quite a bit longer to get to hello... 328k
BUT
{joke}
Then it asked me... DO YOU WANT TO PLAY A GAME?
{/joke}

SKYNET LIVES!!! :wink:

Re: Pseudo Infinite Monkey Theorem

Posted: Tue May 03, 2011 10:35 pm
by Rook Zimbabwe
2nd time... past 2,000,000+ still running and no punctuatiom marks yet...
Image
:mrgreen: I got me some stoopid monkeys this time!

Re: Pseudo Infinite Monkey Theorem

Posted: Wed May 04, 2011 1:19 pm
by Nituvious
I had it run all night(about 13 hours total) to create "Hello world." and didn't get any results! However, a random pause I found this
33292221: u dumb.!2ubz
:o I don't think my laptop likes me very well.

Re: Pseudo Infinite Monkey Theorem

Posted: Wed May 04, 2011 2:56 pm
by c4s
I think a random text generator could get interesting: A good start would be to randomly alternate between vowels and consonants. Then disallow the obviously not usable combinations such as more than 2 consonants/vowels after each other or pointless "jk", "xc", "wq" etc.
I once did that years ago (with German umlauts and common combinations like "sch", "st", "sp" ...) and the results weren't that random, actually quite funny... it somehow looked like Finnish. :D

Re: Pseudo Infinite Monkey Theorem

Posted: Thu May 05, 2011 9:00 am
by Demivec
Nituvious wrote:I had it run all night(about 13 hours total) to create "Hello world." and didn't get any results! However, a random pause I found this
33292221: u dumb.!2ubz
:o I don't think my laptop likes me very well.
I made some modifications to your code to speed it up considerably. I also shortened the target string and changed the count variable to a quad. It took only 8.25 hours to accomplished the target. :)
Define.l IMT_Type = #NO_NUMERICAL
Define.s stringToMake.s = "Why me?!"

Finished creating the sentence 'Why me?!' in 105342152072 attempts. It took 29730 seconds.

Re: Pseudo Infinite Monkey Theorem

Posted: Sat May 07, 2011 10:23 am
by Joakim Christiansen
c4s wrote:I think a random text generator could get interesting: A good start would be to randomly alternate between vowels and consonants. Then disallow the obviously not usable combinations such as more than 2 consonants/vowels after each other or pointless "jk", "xc", "wq" etc.
I once did that years ago (with German umlauts and common combinations like "sch", "st", "sp" ...) and the results weren't that random, actually quite funny... it somehow looked like Finnish. :D
Good idea!

And if storing the random seed one could compress stuff like "hello world" into 4 byte values (.l) when found. It would take a damn long time though to compress a text file and in some situations it might just hang forever (but would be fun to make).

Re: Pseudo Infinite Monkey Theorem

Posted: Sat May 07, 2011 12:13 pm
by pcfreak
My monkey was way too silly. Even after >2 billion I only got things like this:
Image
:?

Re: Pseudo Infinite Monkey Theorem

Posted: Sat May 07, 2011 12:59 pm
by kvitaliy
Problem is similar to solving a password length of 13 characters brute force. Even with the brute force the problem is solved according to the power the computer from several months to several years! And with a random selection problem in general seems impossible in the foreseeable future.

Re: Pseudo Infinite Monkey Theorem

Posted: Sat May 07, 2011 3:00 pm
by Demivec
pcfreak wrote:My monkey was way too silly. Even after >2 billion I only got things like this:
Was that a simulated screen image? Your monkey seemed to be counting down instead of up. :)

I had to speed up the code and shorten the length of the string to match so that I could see a solution in under year.

Re: Pseudo Infinite Monkey Theorem

Posted: Sat May 07, 2011 4:49 pm
by Rook Zimbabwe
pcfreak wrote:My monkey was way too silly. Even after >2 billion I only got things like this:
Image
:?
DUDE... right on -1227054834 you got famsvmorbxzy!!! That is monkey for "where is my bananna!" :mrgreen:

I think it is negative because the number is too high... I wonder if there will be a rollover or if the computer will just crash when it gets to 0

Re: Pseudo Infinite Monkey Theorem

Posted: Mon May 09, 2011 12:28 pm
by Joakim Christiansen
Rook Zimbabwe wrote:I think it is negative because the number is too high... I wonder if there will be a rollover or if the computer will just crash when it gets to 0
It will just roll over.

OR maybe the internet will crash.