Created
January 20, 2026 19:08
-
-
Save justin2004/1266b8521db2133a08f3ec4bc2248546 to your computer and use it in GitHub Desktop.
torus vowels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| torusVowels←{ | |
| v← ⎕av ⍝ vector of chars (that we index into) | |
| c← v⍳⍵ ⍝ c as in cipher text (using indexes instead of chars) | |
| m←c∊v⍳'aeiou' ⍝ mask of vowels | |
| v[(m\¯1⌽0~⍨m×c)+ c×~m] | |
| ⍝ ^ keep the consonants | |
| ⍝ ^ select the only vowels | |
| ⍝ ^ then do a ¯1 rotate to shift them to the right | |
| ⍝ ^ finally expand using the mask so we can recombine vowels and consonants | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def torusVowels(s): | |
| x=[i for i,c in enumerate(s)if c.lower()in"aeiou"] | |
| l=list(s) | |
| for i in range(len(x)):l[x[(i+1)%len(x)]]=s[x[i]]if x else s[x[i]] | |
| return''.join(l) |
Author
justin2004
commented
Jan 20, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment