Comments on Beaver Code Decryption
Parent
Beaver Code Decryption
Credit
This challenge is taken with permission from https://www.mysterytwisterc3.org/en/challenges/level-1/beaver-code
Description
The encryption method is as follows:
The plaintext is divided into two halves, odd positions and even positions.
Example: 'CRYPTO' -> ['CYT','RPO']
This is then applied recursively to both halves, until each part is two letters or less. The parts are then merged.
'CRYPTO' -> ['CYT','RPO'] -> [['CT','Y'], ['RO','P']] -> 'CTYROP'
Challenge
Given a string encrypted with this method, decrypt it.
Valid input formats: ['CTYROP'], 'CTYROP'
Test cases
CTYROP -> CRYPTO
EOYCTNNPRI -> ENCRYPTION
RUOENFSEAFMRDHT -> RANDOMSTUFFHERE
Note: the encryption of the last test case is the same as the decryption, make sure you're decrypting!
BQN, 24 bytesSBCS ``` {gββΌπΒ¨ …
3y ago
Solutions by ngn https://ch …
3y ago
[Jelly], 9 bytes ΕHΓΒΉαΈ? …
3y ago
APL(Dyalog Unicode), 34 29 byt …
3y ago
APL(Dyalog Extended), 32 bytes …
3y ago
[Husk], 8 bytes Ξ£Tm?IβΞ΅ …
3y ago
Post
APL(Dyalog Unicode), 34 29 bytes SBCS
Saved 5 bytes thanks to Razetime!
{2>sββ2Γ·β¨β’β΅:β΅β,βββΒ¨s(β,β₯ββ)β΅}
{2>sββ2Γ·β¨β’β΅:β΅β,βββΒ¨s(β,β₯ββ)β΅}
{ } β Define a dfn taking argument β΅
sβ β s will be the size of one half of β΅
β’β΅ β Length of β΅
2Γ·β¨ β Divided by two
β β Rounded up
2> β If s is 1 (β΅ has 1 or 2 elements):
:β΅ β Just return β΅
β β Otherwise
s(β β)β΅ β Train with first s elements of β΅ on left
β And second half of β΅ on right
β₯ β For both halves
β β Box them
, β Join into vector
βΒ¨ β Run this function again on each half
β β Turn into a character matrix
β β Transpose
, β Concatenate to interleave them together
1 comment thread