# Riffle shuffle a string - Cops

Robbers post

A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string:

• Split the string into equal sections.
• Reverse the strings, and starting from the start of each string.
• Put runs of a uniformly random length between 1 and the number of characters left in the current string into the final string
• Then remove these characters from the string.
• Repeat for the other half, until both halves are empty.

An example

"Hello World!"      Output string = ""
"Hello ", "World!"  ""
"Hell", "World!"    " o"
"Hell", "World"     " o!"
"Hel", "World"      " o!l"
"Hel", "Wo"         " o!ldlr"
"H", "Wo"           " o!ldlrle"
"H", ""             " o!ldlrleoW"
"", ""              " o!ldlrleoWH"


The final product from Hello World! could be o!ldlrleoWH and that is what you would output.

## Cops

Your task is to make a program (or function) that will riffle shuffle a string. If the inputted string is of odd length, just split it into two uneven length strings with a relative length of +1 and +0 (abc => [ab, c] or [a, bc]). You may take input in the normal fashion and produce output in the normal fashion.

Your Cops submission will consist of 4 things

• The language you used
• The length of your program in bytes
• Anything else you want to add

You are aiming to keep your code from being uncracked by the Robbers for 7 days. After that period, your program is safe and you should edit in your original program. Your submission may still be cracked until you reveal your solution. The shortest, safe solution will be the winner!

• – Jonathan Allan Jan 1 '18 at 13:52
• The change to uniformly random makes me a sad dragon. I had fun making an entry using a Wald Distribution (inverse gaussian). I'd love to post it. – Draco18s Jan 11 '18 at 0:04

# Jelly, 11 bytes, Cracked

This is a golfed version so someone can probably crack it easily just by making a golfy version. There are probably a few different approaches but I suspect this approach will be decently common with golfing languages.

Ṗ/Œż€X€U2sœ


The SHA-384 hash of my intended program is 86025a659b3c5fc38e943f72b1f26e28e2e751a7118a589073f1d24fa61ff6b02753d6a0f3f0c7fee6555de69fd06a74 (using UTF-8 encoding).

• Cracked – fireflame241 Jan 1 '18 at 3:58
• @fireflame241 good job +1 – HyperNeutrino Jan 1 '18 at 17:32

# ><>, 46 bytes

 }lr]l:l~\r[-r}x>o?
<!l>x![; ?=\?(0:2i
:,2-%2:


There’s almost no obfuscations in the real code, but I suspect a 2D language will be hard enough to crack anyway.

Disclaimer: Written before it was specified that it had to be uniformly random. This is not uniformly random, and I'm not sure how I'd even implement a uniformly random algorithm in ><> to begin with.

# Python 3, 154 bytes (list of chars -> list of chars) (function) Cracked

[=o;]1-::[]:s[i,]1-::[]s:[i=R,L;2//)i(nel=s
:)i(r fed
*tropmi modR+L+o nruter
]:s[L,R=R,L;]s:[L=+o;))L(nel,1(tnidnar=s:R dna L elihw
]nar morf


I doubt this will be too hard to crack, especially since riffling once is rather ineffective (you can see entire program components in the output...). This is mostly just to get things rolling. There might be some whitespace (including newlines) that I didn't copy correctly. The SHA-384 hash of my intended solution is 5924530418bf8cd603c25da04ea308b124fdddfc61e7060d78b35e50ead69a7fbde9200b5ee16635cc0ee9df9c954fa1.

• @H.PWiz Python. Whoops, forgot to add it in (also bytecount, thanks for the reminder!) – HyperNeutrino Jan 1 '18 at 3:21
• In theory, could you just try reverse riffle shuffling the code and executing it with python until it works? – fəˈnɛtɪk Jan 1 '18 at 3:27
• @fəˈnɛtɪk Theoretically that should work... It may take you a while though :P – HyperNeutrino Jan 1 '18 at 3:28
• @fəˈnɛtɪk That's just like try solving the programming language quiz with TIO brute force. There is no fun in doing it. – user202729 Jan 1 '18 at 3:31
• Recracked – fireflame241 Jan 1 '18 at 19:49

# Röda, 118 bytes

2//x#=z}][=]:y[x
}]0>)b..a(#[]1-::[]:y[x
x#%)(reelihw}]0>b#[fi)b(g
getnI]0>a#[fi)a(g{]mo:z[x=b]zdnar=y|x|{=:[g{xx=a
f


It takes a stream of characters as input and outputs a stream of characters.

# R, 283 bytes, Cracked

/n,s(daeh-<l
))'',s(tilpsrts(le::sdohtem-<s
)s(rahcn-<n{)s(noitcnufhtgnel(fi
})x-,l(liat-<l
)))x,l(daeh(ver,o(c-<o
)1,)l(htgnel(elihw
}{-<o
)2/n,s(liat-<r
)2'=pes,o(tac
}})y-,r(liat-<r
)))y,r(daeh(ver,o(c-<o
)1,)r(htgnel(elpmas-<y{))r(l(fi{))r(htgnel|)l(htgnel()'htgne}(lpmas-<x{))le


I realize now that writing a longer answer has more "runs" of characters that are preserved, alas.

Good luck!

• Cracked – fergusq Jan 2 '18 at 9:38
• @Mr.Xcoder thanks for the edit – Giuseppe Jan 3 '18 at 17:16

# Pyth, 14 bytes, Cracked

_Qm/dc2iF.jk.O


Pretty standard-issue Pyth implementation to test the waters. May be quite easy to crack, but I guess we'll see how it fares.

# Random Brainfuck, 273 bytes

]<.[<<]<[<<]<[<]<,.[<]-<<<]>>>>>]<+>-[<]<+>-[<<]>]>+<]<]>[>>]]>[>>]<]<+>-[[<<]>]>[>>]<-[[[>>]]>[>]<+>-[[<]<[[?>>]<+>-[[<]-<]>]<[>>]<<+>>+>-[[<<,[>]<.[<]>[>]<+>-[<]>[>]->>>]<<<<<]>+-[<<-[>]>+<-[>>]<]<+>-[[[<<]]<[<]>+<-[[><]<[[>]<+>-[>],]<+>-[<]<->>+]>[[<-[<?<<+>>>[,]>+<-[[>


Random brainfuck is the same as normal brainfuck, but it introduces the ? character, which sets the current cell to a random value. Fun note; I had a version of this that only worked for inputs of less than 256 characters, for obvious reasons, but the code itself was longer than that. When I changed it to handle longer, it turned out to be one byte shorter than the original. ¯\_(ツ)_/¯.

# Pushy, 25 bytes, Cracked

iUL1[N@O;?x?v:/2L=0LF;.':


Takes input as a "quoted string" on the command line.

• Cracked – Jo King Jan 9 '18 at 0:26
• Should the 1L be the other way around? Otherwise you're adding 1 to the length – Jo King Jan 9 '18 at 0:35
• @JoKing Correct, and nice crack! – FlipTack Jan 9 '18 at 23:17

# APL (Dyalog Unicode), 62 bytes

(g÷f¨()⍵(≢~⊃⍵⍺⍉⍨⍨}(←(←'')⊂f≢(g∘⌈¨}{?↑-⍵↑⋄)≢)))≢⊂{,⋄⍵⍵↑2f≢∘⊃?()


SHA-384 of my intended solution: 3209dba6ce8abd880eb0595cc0a334be7e686ca0aa441309b7c5c8d3118d877de2a48cbc6af9ef0299477e3170d1b94a

This is probably easy enough, especially since most of the people in the APL chat helped me build this answer.