Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Comments on Beaver Code Decryption

Parent

Beaver Code Decryption

+6
−0

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!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (1 comment)
Post
+2
−0

APL(Dyalog Unicode), 34 29 bytes SBCS

Saved 5 bytes thanks to Razetime!

{2>sβ†βŒˆ2÷⍨≒⍡:⍡⋄,β‰β†‘βˆ‡Β¨s(↑,β₯βŠ‚β†“)⍡}

Try it on APLgolf!

{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
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (1 comment)
General comments
Razetime‭ wrote over 3 years ago

Using Jelly idea: 29 bytes