Do you know your 'KVZ's?Tips for golfing in 05AB1ETwinkle Twinkle Little StarSort, with your hands tied behind your backOutput a shuffled deck using random inputImplement a PCGWrite a program that finds the most occurring paired letter in a stringRead n random lines from a potentially huge fileRandom Golf of the Day #7: A distinctly random characterLangford stringsType the Alphabet - as fast as you can!Make a Bowl of Alphabet Soup
Why is the Intel 8086 CPU called a 16-bit CPU?
Is this Android phone Android 9.0 or Android 6.0?
Company looks for long-term employees, but I know I won't be interested in staying long
How many opportunity attacks can you make per turn before becoming exhausted?
Real orthogonal and sign
Don't individual signal sources affect each other when using a summing amplifier?
Does unblocking power bar outlets through short extension cords increase fire risk?
What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?
Last-minute canceled work-trip mean I'll lose thousands of dollars on planned vacation
Who or what determines if a curse is valid or not?
How to belay quickly ascending top-rope climbers?
Changing iteration variable in Do loop
What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?
How slow ( not zero) can a car engine run without hurting engine and saving on fuel
When will the last unambiguous evidence of mankind disappear?
🍩🔔🔥Scrambled emoji tale⚛️🎶🛒 #2️⃣
Is encryption still applied if you ignore the SSL certificate warning for self-signed certs?
In this iconic lunar orbit rendezvous photo of John Houbolt, why do arrows #5 and #6 point the "wrong" way?
Tuning G3 string to A3 guitar
Is it possible to have a career in SciComp without contributing to arms research?
When designing an adventure, how can I ensure a continuous player experience in a setting that's likely to favor TPKs?
Has sea level rise slowed down?
Operation Unzalgo
Applying for jobs with an obvious scar
Do you know your 'KVZ's?
Tips for golfing in 05AB1ETwinkle Twinkle Little StarSort, with your hands tied behind your backOutput a shuffled deck using random inputImplement a PCGWrite a program that finds the most occurring paired letter in a stringRead n random lines from a potentially huge fileRandom Golf of the Day #7: A distinctly random characterLangford stringsType the Alphabet - as fast as you can!Make a Bowl of Alphabet Soup
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
Concept
In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune?
Rules
Swapping
Let's just assume the letters contained in each of the following sets can be swapped freely by default without ruining the tune:
- A, J, K
- B, C, D, E, G, P, T, V, Z
- I, Y
- Q, U
- S, X, F
- M, N
- Therefore H, L, O, R, and W are locked in place
Output
The program needs to output a single RANDOM string (or list of characters) containing the complete English alphabet in any order provided that order satisfies the conditions above. There should be no way for you to predict which string your program will output(if we ignore seeding), meaning you can't just hardcode it.
Your program must have some positive probability (not necessarily uniform) of generating each of the $ 9! cdot 3! cdot 3! cdot 2! cdot 2! cdot 2! = 104509440 $ outputs.
There are no particular formatting restrictions regarding spacing, delimiters or case, just be consistent.
Goal
Fewest bytes wins!
Examples:
- KCDBPSVHIAJLMNOZQRXGUEWFYT
- A,G,Z,V,P,X,C,H,Y,K,J,L,N,M,O,T,U,R,S,D,Q,B,W,F,I,E
- KVTDCFBHIJALNMOPURSZQGWXYE
- j c d e b x t h i k a l n m o g u r s v q p w f y z
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
Nonexample:
- HLWROABCDEFZXYGIJKMNPQTSVU
Proof of Concept: (Python3, 529 bytes)
import random
g1 = ['A', 'J', 'K']
g2 = ['B', 'C', 'D', 'E', 'G', 'P', 'T', 'V', 'Z']
g3 = ['I', 'Y']
g4 = ['Q', 'U']
g5 = ['S', 'X', 'F']
g6 = ['M', 'N']
random.shuffle(g1)
random.shuffle(g2)
random.shuffle(g3)
random.shuffle(g4)
random.shuffle(g5)
random.shuffle(g6)
print(g1[0] + g2[0] + g2[1] + g2[2] + g2[3] + g5[0] + g2[4] + 'H' + g3[0] + g1[1] + g1[2] + 'L' + g6[0] + g6[1] + 'O' + g2[5] + g4[0] + 'R' + g5[1] + g2[6] + g4[1] + g2[7] + 'W' + g5[2] + g3[1] + g2[8])
code-golf string random
$endgroup$
|
show 12 more comments
$begingroup$
Concept
In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune?
Rules
Swapping
Let's just assume the letters contained in each of the following sets can be swapped freely by default without ruining the tune:
- A, J, K
- B, C, D, E, G, P, T, V, Z
- I, Y
- Q, U
- S, X, F
- M, N
- Therefore H, L, O, R, and W are locked in place
Output
The program needs to output a single RANDOM string (or list of characters) containing the complete English alphabet in any order provided that order satisfies the conditions above. There should be no way for you to predict which string your program will output(if we ignore seeding), meaning you can't just hardcode it.
Your program must have some positive probability (not necessarily uniform) of generating each of the $ 9! cdot 3! cdot 3! cdot 2! cdot 2! cdot 2! = 104509440 $ outputs.
There are no particular formatting restrictions regarding spacing, delimiters or case, just be consistent.
Goal
Fewest bytes wins!
Examples:
- KCDBPSVHIAJLMNOZQRXGUEWFYT
- A,G,Z,V,P,X,C,H,Y,K,J,L,N,M,O,T,U,R,S,D,Q,B,W,F,I,E
- KVTDCFBHIJALNMOPURSZQGWXYE
- j c d e b x t h i k a l n m o g u r s v q p w f y z
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
Nonexample:
- HLWROABCDEFZXYGIJKMNPQTSVU
Proof of Concept: (Python3, 529 bytes)
import random
g1 = ['A', 'J', 'K']
g2 = ['B', 'C', 'D', 'E', 'G', 'P', 'T', 'V', 'Z']
g3 = ['I', 'Y']
g4 = ['Q', 'U']
g5 = ['S', 'X', 'F']
g6 = ['M', 'N']
random.shuffle(g1)
random.shuffle(g2)
random.shuffle(g3)
random.shuffle(g4)
random.shuffle(g5)
random.shuffle(g6)
print(g1[0] + g2[0] + g2[1] + g2[2] + g2[3] + g5[0] + g2[4] + 'H' + g3[0] + g1[1] + g1[2] + 'L' + g6[0] + g6[1] + 'O' + g2[5] + g4[0] + 'R' + g5[1] + g2[6] + g4[1] + g2[7] + 'W' + g5[2] + g3[1] + g2[8])
code-golf string random
$endgroup$
5
$begingroup$
Shouldn'tZ
be "locked in place", it doesn't rhyme with the others?
$endgroup$
– Shaggy
Jul 10 at 7:37
3
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
3
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
8
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
2
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36
|
show 12 more comments
$begingroup$
Concept
In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune?
Rules
Swapping
Let's just assume the letters contained in each of the following sets can be swapped freely by default without ruining the tune:
- A, J, K
- B, C, D, E, G, P, T, V, Z
- I, Y
- Q, U
- S, X, F
- M, N
- Therefore H, L, O, R, and W are locked in place
Output
The program needs to output a single RANDOM string (or list of characters) containing the complete English alphabet in any order provided that order satisfies the conditions above. There should be no way for you to predict which string your program will output(if we ignore seeding), meaning you can't just hardcode it.
Your program must have some positive probability (not necessarily uniform) of generating each of the $ 9! cdot 3! cdot 3! cdot 2! cdot 2! cdot 2! = 104509440 $ outputs.
There are no particular formatting restrictions regarding spacing, delimiters or case, just be consistent.
Goal
Fewest bytes wins!
Examples:
- KCDBPSVHIAJLMNOZQRXGUEWFYT
- A,G,Z,V,P,X,C,H,Y,K,J,L,N,M,O,T,U,R,S,D,Q,B,W,F,I,E
- KVTDCFBHIJALNMOPURSZQGWXYE
- j c d e b x t h i k a l n m o g u r s v q p w f y z
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
Nonexample:
- HLWROABCDEFZXYGIJKMNPQTSVU
Proof of Concept: (Python3, 529 bytes)
import random
g1 = ['A', 'J', 'K']
g2 = ['B', 'C', 'D', 'E', 'G', 'P', 'T', 'V', 'Z']
g3 = ['I', 'Y']
g4 = ['Q', 'U']
g5 = ['S', 'X', 'F']
g6 = ['M', 'N']
random.shuffle(g1)
random.shuffle(g2)
random.shuffle(g3)
random.shuffle(g4)
random.shuffle(g5)
random.shuffle(g6)
print(g1[0] + g2[0] + g2[1] + g2[2] + g2[3] + g5[0] + g2[4] + 'H' + g3[0] + g1[1] + g1[2] + 'L' + g6[0] + g6[1] + 'O' + g2[5] + g4[0] + 'R' + g5[1] + g2[6] + g4[1] + g2[7] + 'W' + g5[2] + g3[1] + g2[8])
code-golf string random
$endgroup$
Concept
In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune?
Rules
Swapping
Let's just assume the letters contained in each of the following sets can be swapped freely by default without ruining the tune:
- A, J, K
- B, C, D, E, G, P, T, V, Z
- I, Y
- Q, U
- S, X, F
- M, N
- Therefore H, L, O, R, and W are locked in place
Output
The program needs to output a single RANDOM string (or list of characters) containing the complete English alphabet in any order provided that order satisfies the conditions above. There should be no way for you to predict which string your program will output(if we ignore seeding), meaning you can't just hardcode it.
Your program must have some positive probability (not necessarily uniform) of generating each of the $ 9! cdot 3! cdot 3! cdot 2! cdot 2! cdot 2! = 104509440 $ outputs.
There are no particular formatting restrictions regarding spacing, delimiters or case, just be consistent.
Goal
Fewest bytes wins!
Examples:
- KCDBPSVHIAJLMNOZQRXGUEWFYT
- A,G,Z,V,P,X,C,H,Y,K,J,L,N,M,O,T,U,R,S,D,Q,B,W,F,I,E
- KVTDCFBHIJALNMOPURSZQGWXYE
- j c d e b x t h i k a l n m o g u r s v q p w f y z
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
Nonexample:
- HLWROABCDEFZXYGIJKMNPQTSVU
Proof of Concept: (Python3, 529 bytes)
import random
g1 = ['A', 'J', 'K']
g2 = ['B', 'C', 'D', 'E', 'G', 'P', 'T', 'V', 'Z']
g3 = ['I', 'Y']
g4 = ['Q', 'U']
g5 = ['S', 'X', 'F']
g6 = ['M', 'N']
random.shuffle(g1)
random.shuffle(g2)
random.shuffle(g3)
random.shuffle(g4)
random.shuffle(g5)
random.shuffle(g6)
print(g1[0] + g2[0] + g2[1] + g2[2] + g2[3] + g5[0] + g2[4] + 'H' + g3[0] + g1[1] + g1[2] + 'L' + g6[0] + g6[1] + 'O' + g2[5] + g4[0] + 'R' + g5[1] + g2[6] + g4[1] + g2[7] + 'W' + g5[2] + g3[1] + g2[8])
code-golf string random
code-golf string random
edited Jul 14 at 21:00
lirtosiast
19.1k4 gold badges42 silver badges114 bronze badges
19.1k4 gold badges42 silver badges114 bronze badges
asked Jul 10 at 7:19
breadlordbreadlord
1211 silver badge7 bronze badges
1211 silver badge7 bronze badges
5
$begingroup$
Shouldn'tZ
be "locked in place", it doesn't rhyme with the others?
$endgroup$
– Shaggy
Jul 10 at 7:37
3
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
3
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
8
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
2
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36
|
show 12 more comments
5
$begingroup$
Shouldn'tZ
be "locked in place", it doesn't rhyme with the others?
$endgroup$
– Shaggy
Jul 10 at 7:37
3
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
3
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
8
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
2
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36
5
5
$begingroup$
Shouldn't
Z
be "locked in place", it doesn't rhyme with the others?$endgroup$
– Shaggy
Jul 10 at 7:37
$begingroup$
Shouldn't
Z
be "locked in place", it doesn't rhyme with the others?$endgroup$
– Shaggy
Jul 10 at 7:37
3
3
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
3
3
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
8
8
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
2
2
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36
|
show 12 more comments
14 Answers
14
active
oldest
votes
$begingroup$
05AB1E, 28 bytes
A.•¬=©ƶÓÄûkTVã”ØζÞ•Dás#€.rJ‡
Outputs as a single lowercase string.
Try it online or verify $n$ random outputs at once.
Explanation:
A # (a) Push the lowercase alphabet
.•¬=©ƶÓÄûkTVã”ØζÞ• # Push compressed string "ajk bcdegptvz iy qu sxf mn"
Dá # (b) Duplicate it, and only keep the letters (removing the spaces)
s# # Swap to get the string again, and split it by spaces
€.r # Shuffle each substring randomly
J # (c) Join it back together to a single string
‡ # Transliterate all characters from (b) to (c) in string (a)
# (and output the result implicitly)
See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•¬=©ƶÓÄûkTVã”ØζÞ•
is "ajk bcdegptvz iy qu sxf mn"
.
$endgroup$
add a comment |
$begingroup$
Python 3, 140 133 124 123 bytes
d=*map(set,'AJK BCDEGPTVZ IY QU SXF MN H L O R W'.split()),
print([d[int(c,16)].pop()for c in'0111141620075581394131a421'])
Try it online!
-1 byte, thanks to Jo King
Python 2, 174 170 158 bytes
from random import*
s=''
for c in'abbbbebHcaaLffObdRebdbWecb':s+=choice(list(set(('AJK BCDEGPTVZ IY QU SXF MN '+c).split()['abcdef'.find(c)])-set(s)))
print s
Try it online!
$endgroup$
add a comment |
$begingroup$
Ruby, 102 bytes
s=[*?A..?Z]*''
%w(AJK BCDEGPTVZ IY QU SXF MN).mape
$><<s
Try it online!
$endgroup$
add a comment |
$begingroup$
Pyth, 59 57 56 bytes
hMeD,Vs.SMJc"ajk bcdegptvz iy qu fsx mn h l o r w"dxLGsJ
Try it online!
Output is an array of lower case letters.
hMeD,Vs.SMJc"ajk bcdegptvz iy qu fsx mn h l o r w"dxLGsJ Implicit: d=" ", G=<lowercase alphabet>
Jc"ajk bcdegptvz iy qu fsx mn h l o r w"d Chop the grouping string on spaces, store in J
sJ Concatenate J into single string
xLG Find the index of each letter in grouping string in the unaltered alphabet
.SMJ Shuffle each group in J
s Concatenate into a single string
,V Pair the shuffled string with their 'correct' positions in the alphabet
eD Order the pairs by the derived positions (last element of each pair)
hM Keep the letter from each pair (the first element)
Implicit print
$endgroup$
add a comment |
$begingroup$
R, 93 91 bytes
`^`=strsplit
L=LETTERS
for(s in el('AJK7BCDEGPTVZ7IY7QU7FSX7MN'^7)^'')L[L%in%s]=sample(s)
L
Try it online!
$endgroup$
add a comment |
$begingroup$
Perl 6, 76 bytes
my@a='A'..'Z';<AJK BCDEGPTVZ IY QU SXF MN>>>.&@a[.ords X-65].=pick(*);@a
Try it online!
Anonymous code block taking no arguments and returning a list of characters.
Explanation:
# Anonymous code block
my@a='A'..'Z'; # Initialise @a as a list of the alphabet
<AJK BCDEGPTVZ IY QU SXF MN> # For each of the sets of letters
>>.&@a[.ords X-65].= # Set those indexes
pick(*) # To a random order
;@a # And return
$endgroup$
add a comment |
$begingroup$
JavaScript - 421 344 328 320 306 280 277 276 ... 176 Bytes
-77 Bytes - on my own
-18 Byte - thanks to @tsh and @Geza Kerecsenyi who made me see what @tsh initially pointed out too
-8 Bytes - thanks to @Geza Kerecsenyi
-14 Bytes - with help of @Geza Kerecsenyi
-28 Bytes - on my own
-3 Bytes - again with with help of @Geza Kerecsenyi
-1 Bytes - how could this happen...
...
-100 Bytes - @Kaiido killed it and via some steps before this whole thing got down to 176 Bytes
Golfed:
c=[,'AJK','BCDEGPTVZ','IY','QU','SXF','MN'].map(s=>[...s]);alert([...'1222252H311L66O24R5242W532'].reduce((o,v)=>o+(+v?(p=>p.splice((Math.random()*p.length)|0,1))(c[v]):v),""))
or try it online!
$endgroup$
1
$begingroup$
You could at least replace ['B','C','D','E','G','P','T','V','Z'] by 'BCDEGPTVZ'.split`` to save some bytes
$endgroup$
– tsh
Jul 10 at 9:32
1
$begingroup$
Try'BCDEGPTVZ'.split``
instead of.split('')
for -2.
$endgroup$
– Geza Kerecsenyi
Jul 10 at 10:54
1
$begingroup$
Also, you can definey=q=>q.split``
at the top of your code, and make all of the arrays strings that you pass intoy()
- e.ga=['A','J','K']
becomesa=y("AJK")
$endgroup$
– Geza Kerecsenyi
Jul 10 at 11:02
1
$begingroup$
And replace'BCDEGPTVZ'.split('')
withy('BCDEGPTVZ')
$endgroup$
– Geza Kerecsenyi
Jul 10 at 11:08
1
$begingroup$
'abcdef'.includes(s)?r(eval(s)):l[i]
$endgroup$
– Geza Kerecsenyi
Jul 10 at 11:54
|
show 10 more comments
$begingroup$
Runic Enchantments, 210 bytes
>yy `AJK`06B$̤$@
>`BCDEGPTVZ`06B$$$$ $̤$y $ $y @
>̤`IY`06Byyy$yyy̤ @
> ̤`QU`06Byy̤ $y @
> ̤`FSX`06B $yy̤$yy@
>y̤ `MN`06Byyy $@
}}f}l3-[r
3-[2'RA?rR1Kl'RAs]1-:0)?l
> ̤`HLORW`06Bo$y $y$y$yy@ ~B͍
Try it online!
The randomization is not uniform as there isn't a good way to do that in Runic. Instead it randomly rotates each collection of letters (e.g. [BCDEGPTVZ]
is one grouping) by some amount (e.g. rotating the above set by 4, where the top of the stack is at the right, the result would be [BCDEGZPTV]
) and then randomly decides whether or not to reverse the stack. It performs these operations 15 times. As a result, all possible orderings are possible but not equally likely. (In the event that this is not enough, increasing it further costs zero bytes, up to 15000 shuffle loops).
This is the section of the code that handles the shuffling:
v vvvv Loop counter
f}l3-[r < Loop entry
[2'RA?r1KRl'RAs]1-:0)?l3-
~improve this answer
$endgroup$
Ruby, 102 bytes
s=[*?A..?Z]*''
%w(AJK BCDEGPTVZ IY QU SXF MN).mape
$><<s
Try it online!
$begingroup$
Runic Enchantments, 210 bytes
>yy `AJK`06B$̤$@
>`BCDEGPTVZ`06B$$$$ $̤$y $ $y @
>̤`IY`06Byyy$yyy̤ @
> ̤`QU`06Byy̤ $y @
> ̤`FSX`06B $yy̤$yy@
>y̤ `MN`06Byyy $@
f}l3-[r
3-[2'RA?rR1Kl'RAs]1-:0)?l
> ̤`HLORW`06Bo$y $y$y$yy@ ~B͍
Try it online!
The randomization is not uniform as there isn't a good way to do that in Runic. Instead it randomly rotates each collection of letters (e.g. [BCDEGPTVZ]
is one grouping) by some amount (e.g. rotating the above set by 4, where the top of the stack is at the right, the result would be [BCDEGZPTV]
) and then randomly decides whether or not to reverse the stack. It performs these operations 15 times. As a result, all possible orderings are possible but not equally likely. (In the event that this is not enough, increasing it further costs zero bytes, up to 15000 shuffle loops).
This is the section of the code that handles the shuffling:
v vvvv Loop counter
f}l3-[r < Loop entry
[2'RA?r1KRl'RAs]1-:0)?l3-
~B͍ < loop exit
^^^^^^ Randomly reverse
^^^^^ Rotate by a random an amount
The rest of the code unrolls into this:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
> `AJK`08B $ $$;
> `BCDEGPTVZ`08B $$$$ $ $ $ $ $;
> `IY`08B $ $;
> `QU`08B $ $;
> `FSX`08B $ $ $;
> `MN`08B $$;
> `HLORW`08Bo $ $ $ $ $;
^ Create IPs
^^^^^^^^^^^^^^^^ Set letter groupings
^^^ Call shuffle function
^^^^^^^^^^^^^^^^^^^^^^^^^^ Print letters
^ Last letter group needs to be sorted
If the letters are left unshuffled (but once-reversed) by changing two bytes the alphabet is printed normally, which can be used to verify that all letter groupings print in the correct places. The whitespace shifting the B
commands out of phase is so that all the IPs can use the function loop at the same time without colliding, and then getting them back into phase again.
To golf, first any space that could be removed on all lines was trimmed, then each two spaces were converted to a y
, and every sequence of yyyy
was converted to ̤
because ̤
and yyyy
are the same amount of delay, but 2 bytes cheaper. The loop exit was also combined with the HLORW
main program segment in order to save on the spacing bytes (12 bytes).
$endgroup$
Runic Enchantments, 210 bytes
>yy `AJK`06B$̤$@
>`BCDEGPTVZ`06B$$$$ $̤$y $ $y @
>̤`IY`06Byyy$yyy̤ @
> ̤`QU`06Byy̤ $y @
> ̤`FSX`06B $yy̤$yy@
>y̤ `MN`06Byyy $@
f}l3-[r
3-[2'RA?rR1Kl'RAs]1-:0)?l
> ̤`HLORW`06Bo$y $y$y$yy@ ~B͍
Try it online!
The randomization is not uniform as there isn't a good way to do that in Runic. Instead it randomly rotates each collection of letters (e.g. [BCDEGPTVZ]
is one grouping) by some amount (e.g. rotating the above set by 4, where the top of the stack is at the right, the result would be [BCDEGZPTV]
) and then randomly decides whether or not to reverse the stack. It performs these operations 15 times. As a result, all possible orderings are possible but not equally likely. (In the event that this is not enough, increasing it further costs zero bytes, up to 15000 shuffle loops).
This is the section of the code that handles the shuffling:
v vvvv Loop counter
f}l3-[r < Loop entry
[2'RA?r1KRl'RAs]1-:0)?l3-
~{{B͍ < loop exit
^^^^^^ Randomly reverse
^^^^^ Rotate by a random an amount
The rest of the code unrolls into this:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
> `AJK`08B $ $$;
> `BCDEGPTVZ`08B $$$$ $ $ $ $ $;
> `IY`08B $ $;
> `QU`08B $ $;
> `FSX`08B $ $ $;
> `MN`08B $$;
> `HLORW`08Bo $ $ $ $ $;
^ Create IPs
^^^^^^^^^^^^^^^^ Set letter groupings
^^^ Call shuffle function
^^^^^^^^^^^^^^^^^^^^^^^^^^ Print letters
^ Last letter group needs to be sorted
If the letters are left unshuffled (but once-reversed) by changing two bytes the alphabet is printed normally, which can be used to verify that all letter groupings print in the correct places. The whitespace shifting the B
commands out of phase is so that all the IPs can use the function loop at the same time without colliding, and then getting them back into phase again.
To golf, first any space that could be removed on all lines was trimmed, then each two spaces were converted to a y
, and every sequence of yyyy
was converted to ̤
because ̤
and yyyy
are the same amount of delay, but 2 bytes cheaper. The loop exit was also combined with the HLORW
main program segment in order to save on the spacing bytes (12 bytes).
answered Jul 11 at 1:35
Draco18sDraco18s
1,8116 silver badges19 bronze badges
1,8116 silver badges19 bronze badges
add a comment |
add a comment |
$begingroup$
Perl 5, 103 91 85 bytes
mapmy%l;@l/./g++;@k/./g=keys%lAJK,BCDEGPTVZ,SXF,IY,QU,MN;say map$k$_||$_,A..Z
Try it online!
This code (ab)uses the fact that Perl's output of hash keys (%l
) is random to create a mapping (%k
) of all the modifiable letters to one of their possible counterparts. At output time, any key that doesn't exist is assumed to be unchanged.
$endgroup$
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
Usingkeys
is definitely a good approach, but you can save 6 bytes usingsort rand 2,...
instead :( Try it online!
$endgroup$
– Dom Hastings
yesterday
add a comment |
$begingroup$
Perl 5, 103 91 85 bytes
mapmy%l;@l/./g++;@k/./g=keys%lAJK,BCDEGPTVZ,SXF,IY,QU,MN;say map$k$_||$_,A..Z
Try it online!
This code (ab)uses the fact that Perl's output of hash keys (%l
) is random to create a mapping (%k
) of all the modifiable letters to one of their possible counterparts. At output time, any key that doesn't exist is assumed to be unchanged.
$endgroup$
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
Usingkeys
is definitely a good approach, but you can save 6 bytes usingsort rand 2,...
instead :( Try it online!
$endgroup$
– Dom Hastings
yesterday
add a comment |
$begingroup$
Perl 5, 103 91 85 bytes
mapmy%l;@l/./g++;@k/./g=keys%lAJK,BCDEGPTVZ,SXF,IY,QU,MN;say map$k$_||$_,A..Z
Try it online!
This code (ab)uses the fact that Perl's output of hash keys (%l
) is random to create a mapping (%k
) of all the modifiable letters to one of their possible counterparts. At output time, any key that doesn't exist is assumed to be unchanged.
$endgroup$
Perl 5, 103 91 85 bytes
mapmy%l;@l/./g++;@k/./g=keys%lAJK,BCDEGPTVZ,SXF,IY,QU,MN;say map$k$_||$_,A..Z
Try it online!
This code (ab)uses the fact that Perl's output of hash keys (%l
) is random to create a mapping (%k
) of all the modifiable letters to one of their possible counterparts. At output time, any key that doesn't exist is assumed to be unchanged.
edited Jul 11 at 3:56
answered Jul 10 at 19:42
XcaliXcali
6,4175 silver badges23 bronze badges
6,4175 silver badges23 bronze badges
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
Usingkeys
is definitely a good approach, but you can save 6 bytes usingsort rand 2,...
instead :( Try it online!
$endgroup$
– Dom Hastings
yesterday
add a comment |
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
Usingkeys
is definitely a good approach, but you can save 6 bytes usingsort rand 2,...
instead :( Try it online!
$endgroup$
– Dom Hastings
yesterday
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
Except Perl's output of hash keys isn't random at all. It's completely deterministic, just influenced by the keys themselves in a way that makes it difficult to predict. That's why this code produces the same output on every run. Dunno whether that disqualifies this approach or not.
$endgroup$
– John Bollinger
Jul 11 at 20:49
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
@JohnBollinger That is only true within a run of a program. Within a single run, the hash order will be the same if the hash is unmodified. Across two runs or with a modification, there is a random seed created during each invocation of perl. Reference
$endgroup$
– Xcali
Jul 11 at 21:23
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
Ok, @Xcali, I stand corrected. I have been at least partially misled, however, by your "Try it online!" link, which repeatedly generates the same output for me. It must be caching, or something.
$endgroup$
– John Bollinger
Jul 11 at 21:27
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
@JohnBollinger Only if you run a sufficiently old version of Perl. Many versions ago, this was changed. A random seed is used in the hashing algorithm, and that seed will be different from run to run. (But you can set an environment variable to disable this feature). This is actually a security feature.
$endgroup$
– Abigail
Jul 12 at 0:00
$begingroup$
Using
keys
is definitely a good approach, but you can save 6 bytes using sort rand 2,...
instead :( Try it online!$endgroup$
– Dom Hastings
yesterday
$begingroup$
Using
keys
is definitely a good approach, but you can save 6 bytes using sort rand 2,...
instead :( Try it online!$endgroup$
– Dom Hastings
yesterday
add a comment |
$begingroup$
Jelly, 34 bytes
ØA“wẸXWỵḲ⁻ȦƙṄṇ’œ?µ“ĠQ’ḃ3ÄœṖ⁸Ẋ€Ẏị@Ụ
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 34 bytes
ØA“wẸXWỵḲ⁻ȦƙṄṇ’œ?µ“ĠQ’ḃ3ÄœṖ⁸Ẋ€Ẏị@Ụ
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 34 bytes
ØA“wẸXWỵḲ⁻ȦƙṄṇ’œ?µ“ĠQ’ḃ3ÄœṖ⁸Ẋ€Ẏị@Ụ
Try it online!
$endgroup$
Jelly, 34 bytes
ØA“wẸXWỵḲ⁻ȦƙṄṇ’œ?µ“ĠQ’ḃ3ÄœṖ⁸Ẋ€Ẏị@Ụ
Try it online!
edited Jul 11 at 10:17
answered Jul 10 at 23:59
Erik the OutgolferErik the Outgolfer
34.9k4 gold badges30 silver badges109 bronze badges
34.9k4 gold badges30 silver badges109 bronze badges
add a comment |
add a comment |
$begingroup$
Python 3, 149 bytes
a,b,i,q,s,m,h,l,o,r,w=(set(s)for s in["AJK","BCDEGPTVZ","IY","QU","SXF","MN",*"HLORW"])
print([eval(c).pop()for c in[*"abbbbsbhiaalmmobqrsbqbwsib"]])
Try it online!
Randomization by using pop() for letter set
$endgroup$
add a comment |
$begingroup$
Python 3, 149 bytes
a,b,i,q,s,m,h,l,o,r,w=(set(s)for s in["AJK","BCDEGPTVZ","IY","QU","SXF","MN",*"HLORW"])
print([eval(c).pop()for c in[*"abbbbsbhiaalmmobqrsbqbwsib"]])
Try it online!
Randomization by using pop() for letter set
$endgroup$
add a comment |
$begingroup$
Python 3, 149 bytes
a,b,i,q,s,m,h,l,o,r,w=(set(s)for s in["AJK","BCDEGPTVZ","IY","QU","SXF","MN",*"HLORW"])
print([eval(c).pop()for c in[*"abbbbsbhiaalmmobqrsbqbwsib"]])
Try it online!
Randomization by using pop() for letter set
$endgroup$
Python 3, 149 bytes
a,b,i,q,s,m,h,l,o,r,w=(set(s)for s in["AJK","BCDEGPTVZ","IY","QU","SXF","MN",*"HLORW"])
print([eval(c).pop()for c in[*"abbbbsbhiaalmmobqrsbqbwsib"]])
Try it online!
Randomization by using pop() for letter set
edited Jul 10 at 10:14
answered Jul 10 at 10:02
JitseJitse
716 bronze badges
716 bronze badges
add a comment |
add a comment |
$begingroup$
APL (Dyalog Extended), 55 bytes
Full program. Prints uppercase with a leading and trailing space, but no intermediary spaces.
(?⍨∘≢⊇⊢)@(∊∘⍺)⊢⍵/⌈'AjkBcdegptvzIyQuSxfMn'(⊂⍤⊢,⍨∊⊂⊣)⎕A
Try it online!
⎕A
the uppercase alphabet
'AjkBcdegptvzIyQuSxfMn'(
…)
apply the following anonymous tacit function with that as right argument and the indicated string as left argument:
⊣
for the left argument,
⊂
partition it, beginning a new segment where
∊
the left arguments characters are members of the right argument (i.e. on uppercase letters)
,⍨
append
⊂
enclose (to treat it as a single element)⍤
the⊢
right argument
⌈
uppercase everything
…
/
reduce by the following anonymous lambda, giving …"QU"λ("SXF"λ("MN"λ"A-Z"))
:
⊢⍵
on the right argument (the scrambling-in-progress alphabet)
(
…)@(∊∘⍺)
apply the following anonymous tacit function to the subset that is a member of the left argument (a rhyme group)
⊢
on that subset
⊇
reorder it to be
?⍨
a random permutation
∘
of length
≢
tally of letters in the subset
$endgroup$
add a comment |
$begingroup$
APL (Dyalog Extended), 55 bytes
Full program. Prints uppercase with a leading and trailing space, but no intermediary spaces.
(?⍨∘≢⊇⊢)@(∊∘⍺)⊢⍵/⌈'AjkBcdegptvzIyQuSxfMn'(⊂⍤⊢,⍨∊⊂⊣)⎕A
Try it online!
⎕A
the uppercase alphabet
'AjkBcdegptvzIyQuSxfMn'(
…)
apply the following anonymous tacit function with that as right argument and the indicated string as left argument:
⊣
for the left argument,
⊂
partition it, beginning a new segment where
∊
the left arguments characters are members of the right argument (i.e. on uppercase letters)
,⍨
append
⊂
enclose (to treat it as a single element)⍤
the⊢
right argument
⌈
uppercase everything
…
/
reduce by the following anonymous lambda, giving …"QU"λ("SXF"λ("MN"λ"A-Z"))
:
⊢⍵
on the right argument (the scrambling-in-progress alphabet)
(
…)@(∊∘⍺)
apply the following anonymous tacit function to the subset that is a member of the left argument (a rhyme group)
⊢
on that subset
⊇
reorder it to be
?⍨
a random permutation
∘
of length
≢
tally of letters in the subset
$endgroup$
add a comment |
$begingroup$
APL (Dyalog Extended), 55 bytes
Full program. Prints uppercase with a leading and trailing space, but no intermediary spaces.
(?⍨∘≢⊇⊢)@(∊∘⍺)⊢⍵/⌈'AjkBcdegptvzIyQuSxfMn'(⊂⍤⊢,⍨∊⊂⊣)⎕A
Try it online!
⎕A
the uppercase alphabet
'AjkBcdegptvzIyQuSxfMn'(
…)
apply the following anonymous tacit function with that as right argument and the indicated string as left argument:
⊣
for the left argument,
⊂
partition it, beginning a new segment where
∊
the left arguments characters are members of the right argument (i.e. on uppercase letters)
,⍨
append
⊂
enclose (to treat it as a single element)⍤
the⊢
right argument
⌈
uppercase everything
…
/
reduce by the following anonymous lambda, giving …"QU"λ("SXF"λ("MN"λ"A-Z"))
:
⊢⍵
on the right argument (the scrambling-in-progress alphabet)
(
…)@(∊∘⍺)
apply the following anonymous tacit function to the subset that is a member of the left argument (a rhyme group)
⊢
on that subset
⊇
reorder it to be
?⍨
a random permutation
∘
of length
≢
tally of letters in the subset
$endgroup$
APL (Dyalog Extended), 55 bytes
Full program. Prints uppercase with a leading and trailing space, but no intermediary spaces.
(?⍨∘≢⊇⊢)@(∊∘⍺)⊢⍵/⌈'AjkBcdegptvzIyQuSxfMn'(⊂⍤⊢,⍨∊⊂⊣)⎕A
Try it online!
⎕A
the uppercase alphabet
'AjkBcdegptvzIyQuSxfMn'(
…)
apply the following anonymous tacit function with that as right argument and the indicated string as left argument:
⊣
for the left argument,
⊂
partition it, beginning a new segment where
∊
the left arguments characters are members of the right argument (i.e. on uppercase letters)
,⍨
append
⊂
enclose (to treat it as a single element)⍤
the⊢
right argument
⌈
uppercase everything
…
/
reduce by the following anonymous lambda, giving …"QU"λ("SXF"λ("MN"λ"A-Z"))
:
⊢⍵
on the right argument (the scrambling-in-progress alphabet)
(
…)@(∊∘⍺)
apply the following anonymous tacit function to the subset that is a member of the left argument (a rhyme group)
⊢
on that subset
⊇
reorder it to be
?⍨
a random permutation
∘
of length
≢
tally of letters in the subset
edited Jul 10 at 12:05
answered Jul 10 at 11:40
AdámAdám
28.9k2 gold badges79 silver badges212 bronze badges
28.9k2 gold badges79 silver badges212 bronze badges
add a comment |
add a comment |
$begingroup$
Charcoal, 43 bytes
FαF⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ” F№κι‽Φκ¬№KAμ
Try it online! Link is to verbose version of code. Charcoal has no shuffling operators, but I came up with a method of sampling without replacement. Explanation:
Fα
Loop over each letter of the alphabet.
F⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ”
Split the string AJK BCDEGPTVZ IY QU SXF MN H L O R W
on spaces and loop over the substrings.
F№κι
Loop over the number of times the current letter appears in the substring. (I use a loop because a conditional would need an else
caluse. Alternatively I could have filtered on the substring containing the current letter for the same byte count.)
‽Φκ¬№KAμ
Print a random character but exclude ones that have already been printed.
$endgroup$
add a comment |
$begingroup$
Charcoal, 43 bytes
FαF⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ” F№κι‽Φκ¬№KAμ
Try it online! Link is to verbose version of code. Charcoal has no shuffling operators, but I came up with a method of sampling without replacement. Explanation:
Fα
Loop over each letter of the alphabet.
F⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ”
Split the string AJK BCDEGPTVZ IY QU SXF MN H L O R W
on spaces and loop over the substrings.
F№κι
Loop over the number of times the current letter appears in the substring. (I use a loop because a conditional would need an else
caluse. Alternatively I could have filtered on the substring containing the current letter for the same byte count.)
‽Φκ¬№KAμ
Print a random character but exclude ones that have already been printed.
$endgroup$
add a comment |
$begingroup$
Charcoal, 43 bytes
FαF⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ” F№κι‽Φκ¬№KAμ
Try it online! Link is to verbose version of code. Charcoal has no shuffling operators, but I came up with a method of sampling without replacement. Explanation:
Fα
Loop over each letter of the alphabet.
F⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ”
Split the string AJK BCDEGPTVZ IY QU SXF MN H L O R W
on spaces and loop over the substrings.
F№κι
Loop over the number of times the current letter appears in the substring. (I use a loop because a conditional would need an else
caluse. Alternatively I could have filtered on the substring containing the current letter for the same byte count.)
‽Φκ¬№KAμ
Print a random character but exclude ones that have already been printed.
$endgroup$
Charcoal, 43 bytes
FαF⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ” F№κι‽Φκ¬№KAμ
Try it online! Link is to verbose version of code. Charcoal has no shuffling operators, but I came up with a method of sampling without replacement. Explanation:
Fα
Loop over each letter of the alphabet.
F⪪”&↖(vJf#S»↖ιηa↷N↖⪪νP´↑x‖υ”
Split the string AJK BCDEGPTVZ IY QU SXF MN H L O R W
on spaces and loop over the substrings.
F№κι
Loop over the number of times the current letter appears in the substring. (I use a loop because a conditional would need an else
caluse. Alternatively I could have filtered on the substring containing the current letter for the same byte count.)
‽Φκ¬№KAμ
Print a random character but exclude ones that have already been printed.
answered Jul 10 at 21:11
NeilNeil
86.4k8 gold badges46 silver badges183 bronze badges
86.4k8 gold badges46 silver badges183 bronze badges
add a comment |
add a comment |
$begingroup$
Retina, 80 bytes
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
~(K`123456
.
?O`$&.¶
)`¶$
[blank line]
d
[blank line]
Try it online!
Probably not the most golfed method, but I'll submit it anyway.
Explanation:
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
Set the working string to 1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
. There is a number before each letter in a group, for example A
, J
and K
all have 1
before them.
~(
Mark a section of code that will produce some retina code, then run it afterwards.
K`123456
Set the working string to 123456
.
?O`$&.¶
Replace each character with ?O`character.¶
)`¶$
[blank line]
Remove the trailing newline and finish the group to generate the code. The group will generate the code:
?O`1.
?O`2.
?O`3.
?O`4.
?O`5.
?O`6.
n.
matches all instances of number n followed by a character. ?O
sorts each instance randomly, and this is done for all character sets.
d
[blank line]
Finally, remove all numbers and implicitly output the generated string.
$endgroup$
add a comment |
$begingroup$
Retina, 80 bytes
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
~(K`123456
.
?O`$&.¶
)`¶$
[blank line]
d
[blank line]
Try it online!
Probably not the most golfed method, but I'll submit it anyway.
Explanation:
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
Set the working string to 1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
. There is a number before each letter in a group, for example A
, J
and K
all have 1
before them.
~(
Mark a section of code that will produce some retina code, then run it afterwards.
K`123456
Set the working string to 123456
.
?O`$&.¶
Replace each character with ?O`character.¶
)`¶$
[blank line]
Remove the trailing newline and finish the group to generate the code. The group will generate the code:
?O`1.
?O`2.
?O`3.
?O`4.
?O`5.
?O`6.
n.
matches all instances of number n followed by a character. ?O
sorts each instance randomly, and this is done for all character sets.
d
[blank line]
Finally, remove all numbers and implicitly output the generated string.
$endgroup$
add a comment |
$begingroup$
Retina, 80 bytes
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
~(K`123456
.
?O`$&.¶
)`¶$
[blank line]
d
[blank line]
Try it online!
Probably not the most golfed method, but I'll submit it anyway.
Explanation:
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
Set the working string to 1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
. There is a number before each letter in a group, for example A
, J
and K
all have 1
before them.
~(
Mark a section of code that will produce some retina code, then run it afterwards.
K`123456
Set the working string to 123456
.
?O`$&.¶
Replace each character with ?O`character.¶
)`¶$
[blank line]
Remove the trailing newline and finish the group to generate the code. The group will generate the code:
?O`1.
?O`2.
?O`3.
?O`4.
?O`5.
?O`6.
n.
matches all instances of number n followed by a character. ?O
sorts each instance randomly, and this is done for all character sets.
d
[blank line]
Finally, remove all numbers and implicitly output the generated string.
$endgroup$
Retina, 80 bytes
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
~(K`123456
.
?O`$&.¶
)`¶$
[blank line]
d
[blank line]
Try it online!
Probably not the most golfed method, but I'll submit it anyway.
Explanation:
K`1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
Set the working string to 1A2B2C2D2E5F2GH3I1J1KL6M6NO2P4QR5S2T4U2VW5X3Y2Z
. There is a number before each letter in a group, for example A
, J
and K
all have 1
before them.
~(
Mark a section of code that will produce some retina code, then run it afterwards.
K`123456
Set the working string to 123456
.
?O`$&.¶
Replace each character with ?O`character.¶
)`¶$
[blank line]
Remove the trailing newline and finish the group to generate the code. The group will generate the code:
?O`1.
?O`2.
?O`3.
?O`4.
?O`5.
?O`6.
n.
matches all instances of number n followed by a character. ?O
sorts each instance randomly, and this is done for all character sets.
d
[blank line]
Finally, remove all numbers and implicitly output the generated string.
answered Jul 11 at 20:20
loladlolad
5242 silver badges14 bronze badges
5242 silver badges14 bronze badges
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f188106%2fdo-you-know-your-kvzs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
$begingroup$
Shouldn't
Z
be "locked in place", it doesn't rhyme with the others?$endgroup$
– Shaggy
Jul 10 at 7:37
3
$begingroup$
Depends on where you are from I suppose. If you say 'zed' then it would make sense to take it out but otherwise, if you say 'zee' then leave it in. Ultimately it's up to you, as are the rest of the sets. They're supposed to be guidelines and starting points opposed to strict rules :)
$endgroup$
– breadlord
Jul 10 at 7:46
3
$begingroup$
Uniformly random or every possibility having a non-zero probability, or something else?
$endgroup$
– jimmy23013
Jul 10 at 9:32
8
$begingroup$
@PeterTaylor I think the intention is that the members of the groups can be easily swapped in the middle of the song while maintaining the tune and rhythm of the original - so while they do rhyme, W is 3 syllables long while U is only 1, which would change the rhythm of the song.
$endgroup$
– Sok
Jul 10 at 10:18
2
$begingroup$
For those who (like me) had no idea what the question was talking about: en.wikipedia.org/wiki/Alphabet_song
$endgroup$
– anatolyg
Jul 11 at 10:36