Author Topic: Shuffling Letters  (Read 4908 times)

0 Members and 1 Guest are viewing this topic.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Shuffling Letters
« on: June 12, 2021, 06:22:49 pm »
Shuffling Letters

This program mixes letters inside words
except for initial and final ones checking language puzzles

Feature of my programs: spinning string
here spinning strings: 5 where goto 5 and 8 where goto 8 and 9 where goto 9

Algorithm: at beginning and at end of string, spaces
i - beginning of found and j - end of found
and except for extreme letters inside word letters are mixed up

Dots change and repeat until end of phrase

Code: QB64: [Select]
  1. RANDOMIZE TIMER ' dashuffle.bas
  2. a$ = " Russians looks World from Future ": d$=a$: a = LEN(a$): i=0: j=1: PRINT a$
  3. open "dashuf.txt" for output as #1: PRINT #1, a$
  4. 5 i = i+1: IF MID$(a$, i, 1) <> " " THEN IF i <= a THEN 5 ELSE END
  5. 7 j = i+1:
  6. 8 IF MID$(a$, j, 1) <> " " THEN IF j <= a THEN j = j+1: GOTO 8 ELSE PRINT a$: END
  7. u = j-2-i-1: PRINT i, j, a
  8. FOR k = 1 TO u
  9.    9 w = INT(i+2+RND*u/2): r = INT(i+2+RND*u/2+u/2): IF w = r THEN 9
  10.  
  11.     q1$ = MID$(d$, 1, w-1)
  12.     w$ = MID$(d$, r, 1)
  13.     q3$ = MID$(d$, w+1, r-w-1)
  14.     r$ = MID$(d$, w, 1)
  15.     q5$ = MID$(d$, r+1, a-r)
  16.     d$ = q1$+w$+q3$+r$+q5$
  17. PRINT d$: PRINT #1, d$: i = j-1: GOTO 5

Results:
Code: [Select]
Russians looks World from Future
1 9 34
Rsaunsis looks World from Future
9 15 34
Rsaunsis lkoos World from Future
15 21 34
Rsaunsis lkoos Wrold from Future
21 26 34
Rsaunsis lkoos Wrold from Future
26 33 34
Rsaunsis lkoos Wrold from Ftruue
Russians looks World from Future

Arocdnicg to rsceearch at Ruiassn Uinervtisy it deosnt mttaer in waht oredr ltteers in a wrod
are olny iprmoatnt tihng is taht frist and lsat ltteer are in rghit pcale
Rset can be a toatl mses and you can sitll raed it wouthit pobelrm
Tihs is buseace huamn mnid deos not raed ervey lteter by istlef but wrod as a wlohe

UPDATE 13jun21
open "dashuf.txt" for output as #1: PRINT #1, a$
PRINT #1, d$:

« Last Edit: June 13, 2021, 01:52:38 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Shuffling Letters
« Reply #1 on: June 13, 2021, 12:04:40 pm »
Amazing

Cchkien fahteres aer dcfulfiit to trhow in a hiruancre

Marked as best answer by DANILIN on July 29, 2021, 02:42:40 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shuffling Letters
« Reply #2 on: July 29, 2021, 06:18:13 am »
Quote
Feature of my programs: spinning string

Here is my version of spinning the middle:
Code: QB64: [Select]
  1. t$ = "Here is the spinMiddle string function." ' b+ 2021-07-29
  2. For i = 1 To Len(t$)
  3.     If Mid$(t$, i, 1) <> " " Then b$ = b$ + Mid$(t$, i, 1)
  4.     If Mid$(t$, i, 1) = " " Then Print spinMiddle$(b$); " ";: b$ = ""
  5. If Len(b$) Then Print spinMiddle$(b$)
  6. Function spinMiddle$ (s$)
  7.     If InStr(",.?!", Right$(s$, 1)) Then t$ = Mid$(s$, 1, Len(s$) - 1) Else t$ = s$
  8.     If Len(t$) > 3 Then
  9.         m$ = Mid$(t$, 2, Len(t$) - 2): r = Int(Rnd * Len(m$)) + 1: If r = 1 Then r = 2
  10.         spinMiddle$ = Left$(t$, 1) + Mid$(m$, r) + Mid$(m$, 1, r - 1) + Right$(t$, 1)
  11.     Else
  12.         spinMiddle$ = t$
  13.     End If
  14.     If InStr(",.?!", Right$(s$, 1)) Then spinMiddle$ = spinMiddle$ + Right$(s$, 1)
  15.  

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Shuffling Letters
« Reply #3 on: July 29, 2021, 09:30:06 am »
Olympic Russian anecdote from 18 century:

2 athletes compete: Russian and American
American athlete finished 2nd
Russian athlete finished penultimate

Read in topic "Guess Number" with comments of anecdote:
https://www.qb64.org/forum/index.php?topic=3999.msg133429#msg133429

? olympic ? ... olympic ... ! olympic !

playlist Sochi2014
https://www.youtube.com/playlist?list=PLBBTP9oVY7IZdH6QaBPhTCfchq6U7OHda


Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shuffling Letters
« Reply #4 on: July 30, 2021, 10:39:48 am »
One thing leads to another...

Code: QB64: [Select]
  1. _Title "ScrollWord$ Function" 'b+ 2021-07-30
  2. ' inspired by idea of spinnimg middle   https://www.qb64.org/forum/index.php?topic=3982.msg134355#msg134355
  3.  
  4. t$ = "Testing this new ScrollWord$ Function. "
  5. c = 1
  6.     Cls
  7.     w = 0
  8.     For i = 1 To Len(t$)
  9.         If Mid$(t$, i, 1) <> " " Then b$ = b$ + Mid$(t$, i, 1)
  10.         If Mid$(t$, i, 1) = " " Then w = w + 1: Locate 3 + w, 37: Print ScrollWord$(b$, c): sw$ = sw$ + ScrollWord$(b$, c) + " ": b$ = ""
  11.     Next
  12.     If Len(b$) Then
  13.         w = w + 1: Locate 3 + w, 37: Print ScrollWord$(b$, c): sw$ = sw$ + ScrollWord$(b$, c)
  14.     End If
  15.     Locate 13, 22: Print sw$
  16.     Locate 17, 22: Print ScrollWord$(t$, c)
  17.     b$ = "": sw$ = "": c = c + 1
  18.     _Display
  19.     _Limit 10
  20.  
  21. Function ScrollWord$ (w$, counter)
  22.     p = counter Mod Len(w$) + 1
  23.     ScrollWord$ = Mid$(w$, p, Len(w$) - p + 1) + Mid$(w$, 1, p - 1)
  24.  

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Shuffling Letters
« Reply #5 on: August 20, 2021, 02:32:27 pm »
it looks like a ... Running strings: September 2019

https://www.qb64.org/forum/index.php?topic=1724.0
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself