Ok, can someone make a code for me that goes through every possible combination of 4 letters/numbers? Like it’ll start with aaaa then aaab then aaac etc. until it has done every possible combination. Thanks so much guys!
I did this once before so here you go. I would guess you’re doing what I was doing because I remember seeing recently a post of yours about using the dictionary. What I did was generate a list of possible combinations and then looped through them looking for their definition. If a definition was found then I knew which 4-letter combinations actually made a real word.
So I think you’re doing the same. Am I right? I was doing it for a game of hang man I created, and used this to find the possible answers of the missing letters in the game. Of course I also have similar handlers for 3-letter and 2 letter combinations. I didn’t go past 4-letters because I figured if I was missing more than 4 letters then I was doing poorly and didn’t deserve the right answer.
EDIT: after a second read of your question I realize you’re just looking for a password generator… so I guess you won’t be using it for a similar purpose as me. :rolleyes:
set lettersList to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
fourLetterCombinations(lettersList)
on fourLetterCombinations(lettersList)
set z to {"", "", "", ""}
set y to {}
repeat with i from 1 to count of lettersList
set item 1 of z to (item i of lettersList)
repeat with j from 1 to count of lettersList
set item 2 of z to (item j of lettersList)
repeat with K from 1 to count of lettersList
set item 3 of z to (item K of lettersList)
repeat with L from 1 to count of lettersList
set item 4 of z to (item L of lettersList)
set end of y to (z as text)
end repeat
end repeat
end repeat
end repeat
return y
end fourLetterCombinations
Hey!!!
I’m not sure that the above post is what you were looking for. Based on your post, I think this might be the way to go:
set letterList to {"a","b","c","d","e","f","g"} --this would continue with the whole alphabet
randomFourLetters(letterList)
on randomFourLetters(letterList)
set cleanList to {}
repeat 4 times
set cleanList's end to some item of letterList
end repeat
return (cleanList as text)
end randomFourLetters
Hope this helps.
L
You can do this in a single line with Ruby:
[code]$ irb
c=“z”; 3.times { puts c; c = c.next }
z
aa
ab
=> 3
[/code]
Or called from an AppleScript:
do shell script "ruby -e 'c=\"z\"; 3.times { puts c; c = c.next }'"
I made a variation of the password generator with more characters to it
set letterList to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "1", "2", "3", "4", "5", "6", "7", "8", "9", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "0", "/", "?"}
randomSevenLetters(letterList)
on randomSevenLetters(letterList)
set cleanList to {}
repeat 7 times
set cleanList's end to some item of letterList
end repeat
return (cleanList as text)
end randomSevenLetters