|
Answer» I would like to try a infinite monkey theorem out. Using a batch file to randomly choose from the 26 letters of the alphabet. When the word banana is spelt the batch file pauses. Any one have any ideas? please anything would help!!!!!!!you can generate a list of lower case letters using for loop. for random function, you can use %RANDOM%.
alternatively, you can use a programming language with functions that deal with random generation. here's a Python implementation
Code: [Select]import random import string import sys letters = string.lowercase #lowercase letters a-z text=sys.argv[1] word=[] #list to contain the letters while 1: #infinite loop word.append(random.sample(letters,1)[0]) #store each letter into array if len(word)== len(text) : if ''.join(word) == text: raw_input("Found : %s" % text) #pause when found. else: print "Generated word: ",''.join(word) word=[] usage: c:\test> python test.py "banana"
if you are interested, here's an executable you can use, if you don't want to download Python.
output:
Code: [Select]C:\test>test.exe banana | more Generated word: rpjjpp Generated word: cclexr Generated word: clqafz Generated word: ewhilx Generated word: jzwhco Generated word: ghjlst Generated word: xsdpff Generated word: lklfhq Generated word: lnolsx Generated word: rpptyy Generated word: jevwvi Generated word: walddh Generated word: pekxbz ..... echo off :loop if %let%==banana goto stop if %num%=6 set let=&set /a word+=1 set /a num+=1 set rnd=%random% if %rnd% gtr 26000 goto loop if %rnd% gtr 25000 set let=%let%z& goto loop if %rnd% gtr 24000 set let=%let%y& goto loop if %rnd% gtr 23000 set let=%let%x& goto loop if %rnd% gtr 22000 set let=%let%w& goto loop if %rnd% gtr 21000 set let=%let%v& goto loop if %rnd% gtr 20000 set let=%let%u& goto loop if %rnd% gtr 19000 set let=%let%t& goto loop if %rnd% gtr 18000 set let=%let%s& goto loop if %rnd% gtr 17000 set let=%let%r& goto loop if %rnd% gtr 16000 set let=%let%Q& goto loop if %rnd% gtr 15000 set let=%let%p& goto loop if %rnd% gtr 14000 set let=%let%o& goto loop if %rnd% gtr 13000 set let=%let%n& goto loop if %rnd% gtr 12000 set let=%let%m& goto loop if %rnd% gtr 11000 set let=%let%l& goto loop if %rnd% gtr 10000 set let=%let%k& goto loop if %rnd% gtr 9000 set let=%let%j& goto loop if %rnd% gtr 8000 set let=%let%i& goto loop if %rnd% gtr 7000 set let=%let%H& goto loop if %rnd% gtr 6000 set let=%let%g& goto loop if %rnd% gtr 5000 set let=%let%f& goto loop if %rnd% gtr 4000 set let=%let%e& goto loop if %rnd% gtr 3000 set let=%let%d& goto loop if %rnd% gtr 2000 set let=%let%c& goto loop if %rnd% gtr 1000 set let=%let%b& goto loop set let=%let%a goto loop :stop echo done! echo %word% pause >nul
that should do it...I had to make that on my dsi so I had to write everything, no copypasta. Helpmeh i put that in to notepad and made a bat from it and its not working please tell me what i need to do. and how i can understand how you made that. pleasetry running the batch file from the command prompt and tell me what it says. (btw, I can't test it as I am STILL on my DSi.)3
Quote from: Helpmeh on June 14, 2009, 06:18:31 AM echo off :loop if %let%==banana goto stop if %num%=6 set let=&set /a word+=1 set /a num+=1 set rnd=%random% if %rnd% gtr 26000 goto loop if %rnd% gtr 25000 set let=%let%z& goto loop if %rnd% gtr 24000 set let=%let%y& goto loop if %rnd% gtr 23000 set let=%let%x& goto loop if %rnd% gtr 22000 set let=%let%w& goto loop if %rnd% gtr 21000 set let=%let%v& goto loop if %rnd% gtr 20000 set let=%let%u& goto loop if %rnd% gtr 19000 set let=%let%t& goto loop if %rnd% gtr 18000 set let=%let%s& goto loop if %rnd% gtr 17000 set let=%let%r& goto loop if %rnd% gtr 16000 set let=%let%q& goto loop if %rnd% gtr 15000 set let=%let%p& goto loop if %rnd% gtr 14000 set let=%let%o& goto loop if %rnd% gtr 13000 set let=%let%n& goto loop if %rnd% gtr 12000 set let=%let%m& goto loop if %rnd% gtr 11000 set let=%let%l& goto loop if %rnd% gtr 10000 set let=%let%k& goto loop if %rnd% gtr 9000 set let=%let%j& goto loop if %rnd% gtr 8000 set let=%let%i& goto loop if %rnd% gtr 7000 set let=%let%h& goto loop if %rnd% gtr 6000 set let=%let%g& goto loop if %rnd% gtr 5000 set let=%let%f& goto loop if %rnd% gtr 4000 set let=%let%e& goto loop if %rnd% gtr 3000 set let=%let%d& goto loop if %rnd% gtr 2000 set let=%let%c& goto loop if %rnd% gtr 1000 set let=%let%b& goto loop set let=%let%a goto loop :stop echo done! echo %word% pause >nul
that should do it...I had to make that on my dsi so I had to write everything, no copypasta.
will %rnd% ever be less than 1000? also what if %rnd% is exactly 1000, 2000, 3000 etc..gh0std0g74 you got this to work? I can't get it going and don't know why is there any other way ? or maybe some links someone could give me to help learn how ?
Quote from: gh0std0g74 on June 14, 2009, 07:04:31 AMwill %rnd% ever be less than 1000? also what if %rnd% is exactly 1000, 2000, 3000 etc..
%rnd% can be less than 1000, and if it is, then %let% will be %let%a. If it is 1000, 2000, etc. then it will be the lower letter, as it is gtr not geq. OP, please use my suggestion of running it from the command prompt, so we can find any error you may have.This here looks like it may take a while before it actually hits with Match for BANANA a counter from AAAAAA to ZZZZZZ would probably hit it sooner counter only really needing to be from AAAAAA to BANANA since everything from BANANB, and BANANC.... to ZZZZZZ is thrown out. Also if random the same combinations can become recreated wasting time. There is a slight chance it could hit BANANA sooner than a counter, but I think the counter would win in counting to BANANA sooner than a random character generation.
Depending on what you have for hardware ( CPU etc ) this could take a while on a Pentium 4 vs a Quad Core etc.
Only STATING this from my project not to long ago to create every combination of A to ZZZZ using FOR A to ZZZZ in a Perl Script that GhostDog helped me with, and write to file for another project and it took a while on a Pentium 4.
I then played with 5 and 6 combination counters and it took about 13 hours to run 6 characters A to ZZZZZZ and write appended to list.txt every combination on the 3Ghz P4 in using Perl and cores were almost 100% the whole time on HT processor.Replacing anything before the if command with if %rnd% geq 15000 goto loop should decrease time. A bit at least...
OP, open the command prompt and drag the batch file into the window and PRESS enter. If it gives an error, you will see it, then you should post it here.
|