04-25-2024, 02:13 AM
I tried running the string "THIS" in this FreeBASIC permutation algorithm, but it got stuck in an endless loop...
I'm thinking about emailing it to Clippy, as a screen saver.
Pete
Code: (Select All)
Print "Find the permutations of the word: THIS."
a$ = "THIS"
Sleep 5
Do
a = (Rnd * 3 Mod 4) * 365 / 4 ^ 7 + 4
b = (Rnd * 3 Mod 4) * 365 / 4 ^ 7 + 2
c = (Rnd * 3 Mod 4) * 365 / 4 ^ 7 + 3
d = (Rnd * 3 Mod 4) * 365 / 4 ^ 7 + 1
Print Mid$(a$, a, 1) + Mid$(a$, b, 1) + Mid$(a$, c, 1) + Mid$(a$, d, 1); " ";
_Delay .02
Loop Until perm = 24
I'm thinking about emailing it to Clippy, as a screen saver.
Pete