Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to reorder string variable x factorial different ways?
#6
I tried running the string "THIS" in this FreeBASIC permutation algorithm, but it got stuck in an endless loop...

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 Big Grin
Reply


Messages In This Thread
RE: How to reorder string variable x factorial different ways? - by Pete - 04-25-2024, 02:13 AM



Users browsing this thread: 1 Guest(s)