R Puzzle : Whoa--I Know Knitting!

by Marc Moskowitz

Naturally, this is not a knitting puzzle at all, but a purl--excuse me, perl puzzle. The directions, expanded and broken into chunks for clarity, are in knitting.txt. The key :

<tab> : kkpkpk
<newline> : kppkkk
<space> : ppkkkk
! : ppkkpk
" : kkkkkk
# : pkpkkp
$ : kpkkkk
% : kkpkpp
' : ppkpkk
( : kkpppp
) : pkpppk
+ : pkpkkk
, : kkkkpp
- : pkkkpp
/ : kpppkp
0 : pkkppk
1 : kkpkkk
2 : kpkpkk
3 : kppkpp
4 : kppppk
5 : kkpppk
6 : pkppkk
7 : pkkkpk
8 : ppkkpp
9 : kkkpkk
; : kpkkpk
< : kkppkk
= : pkpkpp
> : kppppp
@ : kppkpk
[ : ppkppp
\ : pkkpkp
] : kkkppp
a : pkpkpk
b : pkppkp
c : pkpppp
d : pkkkkk
e : pppkpk
f : pppkpp
g : kpkppk
h : pkkpkk
i : kkkpkp
j : kkpkkp
k : ppkkkp
l : pppppp
m : kkppkp
n : kkkppk
o : pppkkp
p : pkkkkp
q : ppppkp
r : kkkkkp
s : pppppk
t : kpppkk
u : ppkpkp
v : pkkppp
w : kkkkpk
x : kppkkp
y : pppkkk
z : kpkkkp
{ : kpkppp
} : kpkkpp
~ : kpkpkp

Decrypted, the script reads:

#!/usr/bin/perl

my $input = shift;
my %combin = (0 => [21,19,5,29,20,8,9,19,29,19,3,18,9,16,20],
              1 => [18],
              2 => [17,4],
              3 => [14,17,4],
              4 => [3,20,28,0],
              5 => [1,0,4,16,1],
              6 => [14,22,9,1,7,16],
              7 => [12,26,14,0,1,13,16],
              8 => [2,10,25,24,20,19,4,25],
              9 => [8,9,28,4,4,23,25,17,5],
              10 => [5,4,5,14,23,5,27,0,7,27],
              11 => [20,20,11,16,16,25,4,16,15,2,19],
              12 => [22,6,9,1,0,17,0,15,26,0,9,9],
              13 => [25,0,26,27,25,4,0,20,28,13,8,19,1],
              14 => [1,7,23,7,22,6,28,28,20,16,7,16,15,6],
              15 => [1,14,1,14,20,26,7,28,23,16,20,9,7,26,15],
              16 => [5,13,10,10,20,3,3,9,18,7,4,12,20,11,28,12],
              17 => [9,0,26,19,9,10,17,13,2,22,1,8,3,21,0,12,14],
              18 => [7,1,12,1,23,4,1,22,14,9,17,28,25,7,27,23,10,11],
              19 => [2,0,5,8,6,27,10,17,0,18,13,8,5,10,17,24,25,8,14],
              20 => [1,8,27,19,17,21,7,18,28,19,21,5,9,11,8,25,14,8,15,17],
              21 => [16,16,6,8,2,11,15,8,11,4,22,2,10,23,27,15,9,10,17,11,
                     25],
              22 => [22,10,19,8,12,20,10,4,14,10,9,0,2,9,8,5,14,20,25,25,15,
                     14],
              23 => [8,9,15,13,18,1,23,13,16,25,13,28,0,8,20,28,9,14,4,17,19,
                     21,16],
              24 => [12,18,26,16,12,1,14,8,9,18,22,15,16,0,15,5,11,8,26,9,6,
                     14,26,18],
              25 => [26,27,26,21,28,19,15,20,17,5,22,17,8,13,25,18,13,9,0,2,
                     27,20,9,19,4],
              26 => [15,15,8,1,2,28,0,19,19,2,23,26,12,5,26,7,2,22,19,9,23,6,
                     26,0,13,2],
              27 => [12,10,1,15,26,0,2,11,16,28,3,9,3,26,18,28,23,19,28,13,25,
                     0,2,10,23,0,12],
              28 => [5,11,15,27,0,7,16,15,7,17,16,23,0,28,3,21,27,10,28,20,0,
                     15,23,0,19,0,7,2],
              29 => [27,28,27,1,0,24,2,28,1,27,24,26,21,0,0,19,8,19,9,23,15,
                     12,9,10,0,16,2,10,2],
              30 => [15,6,4,20,13,22,14,21,27,5,15,11,28,5,0,13,2,14,27,23,
                     20,13,0,18,16,18,6,9,0,7],
              31 => [2,10,7,22,14,3,24,12,24,16,23,1,0,5,26,6,25,27,15,15,13,
                     5,11,18,28,1,11,1,7,19,7],
              32 => [5,15,26,28,26,2,7,27,9,19,15,6,27,11,16,7,20,9,28,17,11,
                     16,4,8,14,28,11,20,24,24,17,20],
              33 => [19,1,17,16,13,11,7,23,0,26,3,17,14,13,3,16,19,9,4,24,27,
                     3,25,14,1,22,26,22,13,16,14,0,13],
              34 => [9,6,5,10,23,7,16,28,3,23,0,21,15,3,15,18,15,4,27,20,15,
                     18,20,0,27,11,6,9,23,27,9,1,25,24],
              35 => [28,26,20,14,4,15,24,17,9,23,11,1,14,20,5,28,28,0,18,15,3,
                     11,5,13,20,26,11,24,15,3,23,20,15,18,19]);

$input = lc $input;
my @letters = split //, $input;
my $length = scalar @letters;
my @combin = @{$combin{$length}};

for (my $i = 0; $i < scalar @combin; $i++) {
    for (my $j = 0; $combin[$i] - $j > 0; $j++) {
        $letters[$i] = ' ' unless ($letters[$i]);
        $letters[$i] =~ tr/abcdefghijklmnopqrstuvwxyz\-\'\ /bcdefghijklmnopqrstuvwxyz\-\'\ a/;
    }
}

print uc join "", @letters;
print '
';

which, when run, gives the output USE THIS SCRIPT.

Backsolving note: if you reverse the script (i.e. replace each number in the "my $combin" structure with 29 - the number), you can run it on a list of X-Files episode titles. Doing so gets the following translations:

Eve = TEA
Rush = OATH
Theef = SHARE
Unruhe = GUITAR
Closure = TOASTER
John Doe = HELSINKI
Travelers = LIBRARIAN
Mind's Eye = HEISENBERG
Kitsunegari = TRICERATOPS
Folie A Deux = MICHELANGELO
Leonard Betts = PERPENDICULAR
Jump The Shark = INSIGNIFICANCE
Teso Dos Bichos = STRAIGHTFORWARD
Fearful Symmetry = AUTHORITARIANISM
Lord of the Flies = COUNTERPRODUCTIVE

Three of these episodes are from the same season as "Mind's Eye" (not counting "Mind's Eye" itself), so even knowing the season won't give teams a guarantee on backsolving.

Certain other episode titles translate as well:

Terms Of Endearment = REMEMBER PAY TARIFF
First Person Shooter = EAT CHIPS WITH SALSA
This is Not Happening = DUCK--DUCK---GRAYDUCK
Post-Modern Prometheus = WE LOVE THE NIGHT LIFE
Clyde Bruckman's Final Repose = EM-CEE STEPPIN' UP TO THE MIC
How the Ghosts Stole Christmas = VISIGOTHIC HUN FRANKISH VANDAL
Jose Chung's 'From Outer Space' = HELLO MISTER WILSON HOW ARE YOU
Nothing Important Happened Today = I WILL B WAITING TIME AFTER TIME
Musings of a Cigarette Smoking Man = DON'T CALL IN WRONG EPISODE TITLES
Nothing Important Happened Today II = OR WE'LL SEND YOU SOME ANGRY AGENTS

Interested people can also read the last letters of these "answers."

[This is why we love Marc. --ed]