11
2
You are given an encrypted string, encrypted using a very simple substitution cipher.
Problem
You do not know what the cipher is but you do know the ciphertext is English and that the most frequent letters in English are etaoinshrdlucmfwypvbgkqjxz in that order. The only allowed characters are uppercase letters and spaces. You can do basic analysis - starting from single letters, but you can migrate onto more complex multi-letter analysis - for example, U almost always follows Q, and only certain letters can come twice in a row.
Examples
clear : SUBMARINE TO ATTACK THE DOVER WAREHOUSE AND PORT ON TUESDAY SUNRISE
cipher: ZOQ DUPAEYSRYDSSDXVYSHEYNRBEUYLDUEHROZEYDANYKRUSYRAYSOEZNDMYZOAUPZE
clear : THE QUICK BROWN FOX BEING QUITE FAST JUMPED OVER THE LAZY DOG QUITE NICELY
cipher: TNAEPDHIGEMZQJLEVQBEMAHL EPDHTAEVXWTEODYUASEQKAZETNAERXFCESQ EPDHTAELHIARC
clear : BUFFALO BUFFALO BUFFALO BUFFALO BUFFALO BUFFALO BUFFALO
cipher: HV WRPDHV WRPDHV WRPDHV WRPDHV WRPDHV WRPDHV WRP
Challenges
See if you can decrypt the text in each of these ciphers:
SVNXIFCXYCFSXKVVZXIHXHERDXEIYRAKXZCOFSWHCZXHERDXBNRHCXZR RONQHXORWECFHCUH
SOFPTGFIFBOKJPHLBFPKHZUGLSOJPLIPKBPKHZUGLSOJPMOLEOPWFSFGJLBFIPMOLEOPXULBSIPLBP
KBPBPWLIJFBILUBKHPGKISFG
TMBWFYAQFAZYCUOYJOBOHATMCYNIAOQW Q JAXOYCOCYCHAACOCYCAHGOVYLAOEGOTMBWFYAOBFF
ACOBHOKBZYKOYCHAUWBHAXOQW XITHJOV WOXWYLYCU
FTRMKRGVRFMHSZVRWHRSFMFLMBNGKMGTHGBRSMKROKLSHSZMHKMMMMMRVVLVMPRKKOZRMFVDSGOFRW
I have the substitution matrices and cleartext for each, but I will only reveal them if it becomes too difficult or someone doesn't figure it out.
The solution which can decrypt the most messages successfully is the winner. If two solutions are equally good, they will be decided by vote counts.
3What defines »most elegant«? I think that's the same thing that Chris objected in 99 bottles already. It's a subjective criterion that's quite hard to judge. – Joey – 2011-01-31T00:07:49.703
@Joey Most upvotes? Let the community decide. – Thomas O – 2011-01-31T00:14:43.953
2
Re "most upvotes": I'm unhappy to see this become a popularity contest post, not least because the post is otherwise excellent; see http://meta.codegolf.stackexchange.com/questions/110/a-modest-proposal-the-popularity-contest-tag for my thoughts on the whole matter.
– Chris Jester-Young – 2011-01-31T01:12:34.5302What does "elegant" mean here? Best big-O performance? – gnibbler – 2011-01-31T03:31:05.253
@Chris, what do you suggest? – Thomas O – 2011-01-31T08:11:23.727
@Thomas: I think mootinator's response to my post is a good middle ground. If nothing else, it will help you articulate clearly what you are expecting. Personally, I prefer to use a cut-and-dried winning criterion, simply because that has less potential for dispute, but, the fact that mootinator responded the way he had says that reasonable people can disagree on the level of black-and-whiteness required. Which I can live with---just be upfront with what you want. – Chris Jester-Young – 2011-01-31T08:36:16.277
@Thomas: In other words, if you want "elegant", at least define clearly what "elegant" means, so we're not dealing with blind men and an elephant.
– Chris Jester-Young – 2011-01-31T08:40:16.880@chris, I've changed it to a challenge then. – Thomas O – 2011-01-31T09:04:06.720
Can we use a dictionary? – st0le – 2011-01-31T12:52:59.517
@st0le you can use anything you need. – Thomas O – 2011-01-31T13:15:32.707
@Thomas: Thanks for the revision; ability to decrypt most messages seems to be easier to measure. – Chris Jester-Young – 2011-01-31T14:23:38.417
The last cipher has 5 M's in a row, but there are no words that I could find with more than 4 repeating letters. Is this an error in the cipher? – Kevin Brown – 2011-02-01T22:25:16.757
1@Bass5098, nope. It's just a difficult ciphertext which has been tainted to make it more resilient to frequency analysis. – Thomas O – 2011-02-01T22:42:25.547