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

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,263 12-19-2025, 12:51 PM
Last Post: Heimdall
  Sub not Reconizing Dim as String pmackay 18 1,477 10-16-2025, 03:32 PM
Last Post: pmackay
  for performance, what's the best variable type to use for boolean _TRUE & _FALSE ? madscijr 12 1,263 09-29-2025, 02:59 PM
Last Post: dakra137
  Illegal string-number conversion Herve 7 775 07-07-2025, 09:53 AM
Last Post: a740g
  need help printing a scaled string in a custom font to a 32-bit image madscijr 9 1,168 07-03-2025, 04:48 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)