>> % Name: Anita Blake              Partner: Ted Forrester
>> % ID:   014916                   ID:      642708
>> % Sec:  Yan T 2:30               Sec:     Artemov R 1:25
>> 
>> plain = 'We Apologize for the Inconvenience';
>> julius = 'abnocdgpwxyefqrstuvhijklmz';
>> caesar = 'deqrfgjszabhituvwxyklmnopc';
>> cipher = transform(julius,caesar,plain);
>> plain2 = transform(caesar,julius,cipher);
>> ok = all(plain == plain2);
>> plain, julius, caesar, cipher, plain2, ok

plain =

We Apologize for the Inconvenience


julius =

abnocdgpwxyefqrstuvhijklmz


caesar =

deqrfgjszabhituvwxyklmnopc


cipher =

Zh Dsrorjlch iru wkh Lqfrqyhqlhqfh


plain2 =

We Apologize for the Inconvenience


ok =

     1

>> 
>> plain= 'Time to feed the chickens, Paw!  Ay-yup!  Git the lunch bag, Maw!';
>> top = 'sLvWPdEncFRjQBahOItMzgyxku';
>> bot = 'CpaTQoweZirBYVhlndxSMKuGfj';
>> cipher = transform(top,bot,plain);
>> plain2 = transform(bot,top,cipher);
>> ok = all(plain == plain2);
>> plain, julius, caesar, cipher, plain2, ok

plain =

Time to feed the chickens, Paw!  Ay-yup!  Git the lunch bag, Maw!


julius =

abnocdgpwxyefqrstuvhijklmz


caesar =

deqrfgjszabhituvwxyklmnopc


cipher =

Xdsw xn iwwo xlw zldzfwec, Qht!  Hu-ujq!  Kdx xlw pjezl vhk, Sht!


plain2 =

Time to feed the chickens, Paw!  Ay-yup!  Git the lunch bag, Maw!


ok =

     1

>> 
>> s = ['a-aAa,-aBBA-23-aBC-ac-AD-13-' ...
     '-ada-<aDD>-..-Baa-^^bad-cAB-&cb-CDC-dab-dad-DADA-dc'];
>> [tot,uni,bi] = tally(s);
read 64 characters
>> s,tot,num2str(uni*tot),num2str(bi*tot),uni(1:6),bi(1:6,1:6)

s =

a-aAa,-aBBA-23-aBC-ac-AD-13--ada-<aDD>-..-Baa-^^bad-cAB-&cb-CDC-dab-dad-DADA-dc


tot =

    64


ans =

17  20   8   7  12   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0


ans =

0  8  2  3  4  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
6  3  4  1  6  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
3  3  1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
4  1  1  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
4  5  0  2  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0


ans =

    0.2656    0.3125    0.1250    0.1094    0.1875         0


ans =

         0    0.1250    0.0312    0.0469    0.0625         0
    0.0938    0.0469    0.0625    0.0156    0.0938         0
    0.0469    0.0469    0.0156    0.0156         0         0
    0.0625    0.0156    0.0156         0    0.0156         0
    0.0625    0.0781         0    0.0312    0.0156         0
         0         0         0         0         0         0

>> 
>> decrypt('oldannounce.txt','challenge.txt')
reading oldannounce.txt...read 17272 characters
reading challenge.txt...read 387 characters

elapsed_time =

    2.4201

swap a<-->v; distance 1.4460; labels  abcdefghijklmnopqrstuvwxyz
swap b<-->s; distance 1.3842; labels  vbcdefghijklmnopqrstuawxyz
swap c<-->z; distance 1.3510; labels  vscdefghijklmnopqrbtuawxyz
swap d<-->q; distance 1.3097; labels  vszdefghijklmnopqrbtuawxyc
swap e<-->f; distance 1.2735; labels  vszqefghijklmnopdrbtuawxyc
swap e<-->i; distance 1.2569; labels  vszqfeghijklmnopdrbtuawxyc
swap g<-->t; distance 1.1816; labels  vszqfighejklmnopdrbtuawxyc
swap h<-->u; distance 1.1507; labels  vszqfithejklmnopdrbguawxyc
swap e<-->y; distance 1.1269; labels  vszqfituejklmnopdrbghawxyc
swap j<-->p; distance 1.0975; labels  vszqfituyjklmnopdrbghawxec
swap k<-->x; distance 1.0866; labels  vszqfituypklmnojdrbghawxec
swap l<-->e; distance 1.0530; labels  vszqfituypxlmnojdrbghawkec
swap m<-->a; distance 1.0380; labels  vszqfituypxemnojdrbghawklc
swap n<-->a; distance 1.0086; labels  vszqfituypxeanojdrbghmwklc
swap o<-->n; distance 0.9989; labels  vszqfituypxenaojdrbghmwklc
swap j<-->o; distance 0.9986; labels  vszqfituypxeoanjdrbghmwklc
swap d<-->c; distance 0.9983; labels  vszqfituypxejanodrbghmwklc
swap r<-->f; distance 0.9009; labels  vszqfituypxejanocrbghmwkld
swap b<-->y; distance 0.8630; labels  vszqrituypxejanocfbghmwkld
swap m<-->x; distance 0.8576; labels  vszqritubpxejanocfyghmwkld
swap w<-->j; distance 0.8481; labels  vszqritubpmejanocfyghxwkld
swap k<-->p; distance 0.8400; labels  vszqritubpmewanocfyghxjkld
swap d<-->c; distance 0.8394; labels  vszqritubkmewanocfyghxjpld
swap v<-->n; distance 0.8360; labels  vszqritubkmewanodfyghxjplc
swap s<-->i; distance 0.8233; labels  nszqritubkmewavodfyghxjplc
swap z<-->w; distance 0.8195; labels  nizqrstubkmewavodfyghxjplc
swap s<-->x; distance 0.8101; labels  niwqrstubkmezavodfyghxjplc
swap b<-->v; distance 0.7759; labels  niwqrxtubkmezavodfyghsjplc
swap k<-->c; distance 0.7710; labels  niwqrxtuvkmezabodfyghsjplc
swap m<-->s; distance 0.7648; labels  niwqrxtuvcmezabodfyghsjplk
swap e<-->f; distance 0.7642; labels  niwqrxtuvcsezabodfyghmjplk
swap y<-->f; distance 0.6772; labels  niwqrxtuvcsfzabodeyghmjplk
swap p<-->w; distance 0.6756; labels  niwqrxtuvcsyzabodefghmjplk
swap k<-->w; distance 0.6753; labels  nipqrxtuvcsyzabodefghmjwlk
swap d<-->w; distance 0.6738; labels  nipqrxtuvcsyzabodefghmjklw

elapsed_time =

    7.3442

decryption key:
nipqrxtuvcsyzabowefghmjkld
abcdefghijklmnopqrstuvwxyz
What I am thinfing (semi-out loud here) is that writing used to
encomjass barious "genres" in one story.  It seems life poofs habe
gotten so sjecialived, kew stories do that well any more.  I thinf
that Laurell F Hamilton, Diana Gapaldon, and Lois McMaster Puqold do a
good qop ok preafing some ok these parriers, put I am not sure I would
say their writing is lasting (as much I would life it to pe:)).

ans =

     []

>> 
>> decrypt('oldannounce.txt','official.txt')
reading oldannounce.txt...read 17272 characters
reading official.txt...read 1452 characters

elapsed_time =

    2.5472

swap a<-->j; distance 1.4586; labels  abcdefghijklmnopqrstuvwxyz
swap b<-->e; distance 1.4238; labels  jbcdefghiaklmnopqrstuvwxyz
swap c<-->s; distance 1.3966; labels  jecdbfghiaklmnopqrstuvwxyz
swap d<-->q; distance 1.3504; labels  jesdbfghiaklmnopqrctuvwxyz
swap b<-->q; distance 1.1853; labels  jesqbfghiaklmnopdrctuvwxyz
swap f<-->t; distance 1.1354; labels  jesbqfghiaklmnopdrctuvwxyz
swap g<-->n; distance 1.1056; labels  jesbqtghiaklmnopdrcfuvwxyz
swap h<-->c; distance 1.0698; labels  jesbqtnhiaklmgopdrcfuvwxyz
swap i<-->l; distance 1.0384; labels  jesbqtnciaklmgopdrhfuvwxyz
swap a<-->o; distance 0.9705; labels  jesbqtnclakimgopdrhfuvwxyz
swap k<-->v; distance 0.9625; labels  jesbqtnclokimgapdrhfuvwxyz
swap i<-->h; distance 0.9202; labels  jesbqtnclovimgapdrhfukwxyz
swap m<-->c; distance 0.8897; labels  jesbqtnclovhmgapdrifukwxyz
swap g<-->h; distance 0.8505; labels  jesbqtnmlovhcgapdrifukwxyz
swap a<-->z; distance 0.8429; labels  jesbqtnmlovgchapdrifukwxyz
swap p<-->a; distance 0.8061; labels  jesbqtnmlovgchzpdrifukwxya
swap d<-->n; distance 0.7730; labels  jesbqtnmlovgchzadrifukwxyp
swap i<-->f; distance 0.7101; labels  jesbqtdmlovgchzanrifukwxyp
swap u<-->a; distance 0.6759; labels  jesbqtdmlovgchzanrfiukwxyp
swap k<-->o; distance 0.6705; labels  jesbqtdmlovgchzunrfiakwxyp
swap w<-->u; distance 0.6647; labels  jesbqtdmlkvgchzunrfiaowxyp
swap x<-->y; distance 0.6571; labels  jesbqtdmlkvgchzwnrfiaouxyp
swap x<-->o; distance 0.6487; labels  jesbqtdmlkvgchzwnrfiaouyxp
swap p<-->n; distance 0.6482; labels  jesbqtdmlkvgchzwnrfiaxuyop
swap e<-->k; distance 0.6406; labels  jesbqtdmlkvgchzwprfiaxuyon
swap s<-->u; distance 0.6354; labels  jksbqtdmlevgchzwprfiaxuyon
swap b<-->d; distance 0.6172; labels  jkubqtdmlevgchzwprfiaxsyon
swap t<-->w; distance 0.6129; labels  jkudqtbmlevgchzwprfiaxsyon
swap l<-->z; distance 0.5598; labels  jkudqwbmlevgchztprfiaxsyon
swap e<-->y; distance 0.5542; labels  jkudqwbmzevgchltprfiaxsyon
swap v<-->w; distance 0.5457; labels  jkudqwbmzyvgchltprfiaxseon
swap g<-->c; distance 0.5230; labels  jkudqvbmzywgchltprfiaxseon
swap g<-->o; distance 0.5055; labels  jkudqvbmzywcghltprfiaxseon
swap k<-->w; distance 0.4885; labels  jkudqvbmzywcohltprfiaxsegn
swap u<-->d; distance 0.4544; labels  jwudqvbmzykcohltprfiaxsegn

elapsed_time =

    7.4439

decryption key:
jwduqvbmzykcohltprfiaxsegn
abcdefghijklmnopqrstuvwxyz
to secret operative from evil group of people:
have you infiltrated bureau thirteen yet? beware of yan and 
especially dis; they might be onto us. beware also artemov -- we have
reason to suspect he is a double agent, and not just because of his
ethnicity! whoever thought of such a silly stereotype? anyway,
internal reviews by our advisory panel concluded that our plans might backfire,
since we actually live on the same world we're supposedly trying to
nuke -- we're supposed to be "evil," not hella lame or hella stupid. 
our new goal is to make a lot of money to fund future egop projects 
since we're draining our budget on these blasted encryption keys that are

ans =

     []