Here's a python puzzle. Solve it and you win a prize. :)
"""
Ha'f ahoy ad ayfa wdqr srxhekdpyr! H phmm zhby
fhv odeajf dc cryy pys jdfahez ad ajy chrfa kyrfde
ad fdmby ajhf irwkadzrxo. Ixe wdq chzqry ha dqa?
Fheiy wdq jxby axgye ow ijxmmyezy xet tyirwkayt
ajy fyirya oyffxzy, H phmm ybye zhby wdq ajy
irwkadzrxo-oxghez fdqriy idty ad xoxuy wdqr
crhyetf!
"""
hokdra fwf, farhez, rxetdo
ihkjyr = mhfa(farhez.myaayrf[:26])
rxetdo.fjqccmy(ihkjyr)
ihkjyr = "".ldhe(ihkjyr)
ihkjyr += ihkjyr.qkkyr()
oxk = {}
cdr kmxhe, irwka he uhk(farhez.myaayrf, ihkjyr):
oxk[kmxhe] = irwka
cdr mhey he dkye(fwf.xrzb[1]):
krhea "".ldhe([oxk.zya(ij,ij) cdr ij he mhey])[:-1]
Cheers,
- Michal http://www.sabren.net/ sab...@manifestation.com
------------------------------------------------------------
Switch to Cornerhost! http://www.cornerhost.com/
Low Priced, Reliable Blog Hosting, With a Human Touch. :)
------------------------------------------------------------
Since you have taken my challenge and decrypted
the secret message, I will even give you the
cryptogram-making source code to amaze your
friends!
import sys, string, random
cipher = list(string.letters[:26])
random.shuffle(cipher)
cipher = "".join(cipher)
cipher += cipher.upper()
map = {}
for plain, crypt in zip(string.letters, cipher):
map[plain] = crypt
for line in open(sys.argv[1]):
print "".join([map.get(ch,ch) for ch in line])[:-1]
--
Novell DeveloperNet Sysop #5
_
"Michal Wallace" <sab...@manifestation.com> wrote in message
news:mailman.1032989974...@python.org...
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
> Here's a python puzzle. Solve it and you win a prize. :)
tr hokdrafwfezxtculyjqmbipsvHIFg importsysngadfzjehulvcwbxICSk
I started by decoding the (obvious) Python source, which made the job
considerably easier.
--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Seriousness is the only refuge of the shallow.
\__/ Oscar Wilde
Church / http://www.alcyone.com/pyos/church/
A lambda calculus explorer in Python.
OK. something like
def decrypt(yourstring):
dedict = {'F': 'S', 'I': 'C', 'H': 'I', 'a': 't', 'c': 'f', 'b': 'v', 'e': 'n',
'd': 'o', 'f': 's', 'i': 'c', 'h': 'i', 'k': 'p', 'j': 'h', 'm': 'l',
'l': 'j', 'o': 'm', 'q': 'u', 'p': 'w', 's': 'b', 'u': 'z', 't': 'd',
'w': 'y', 'v': 'x', 'y': 'e', 'x': 'a', 'z': 'g', 'g': 'k'}
return "".join([dedict.get(i,i) for i in yourstring])
returns
"""
It's time to test your brainpower! I will give
six months of free web hosting to the first person
to solve this cryptogram. Can you figure it out?
Since you have taken my challenge and decrypted
the secret message, I will even give you the
cryptogram-making source code to amaze your
friends!
"""
import sys, string, random
cipher = list(string.letters[:26])
random.shuffle(cipher)
cipher = "".join(cipher)
cipher += cipher.upper()
map = {}
for plain, crypt in zip(string.letters, cipher):
map[plain] = crypt
for line in open(sys.argv[1]):
print "".join([map.get(ch,ch) for ch in line])[:-1]
but i don't know if i need free webhosting :-)
regards,
holger
I decrypted (building the strings up character by character) with:
tr hokdrawfezxmylqcubijHpvsIFgt importysngalejufzvchIwxbCSkd < puzzle
and got:
"""
It's time to test your brainpower! I will give
six months of free web hosting to the first person
to solve this cryptogram. Can you figure it out?
Since you have taken my challenge and decrypted
the secret message, I will even give you the
cryptogram-making source code to amaze your
friends!
"""
import sys, string, random
cipher = list(string.letters[:26])
random.shuffle(cipher)
cipher = "".join(cipher)
cipher += cipher.upper()
map = {}
for plain, crypt in zip(string.letters, cipher):
map[plain] = crypt
for line in open(sys.argv[1]):
print "".join([map.get(ch,ch) for ch in line])[:-1]
The fact that this puzzle was easy to decrypt says something (good)
about Python: It is so readable, that even encrypted, one can
recognize significant portions. Imagine decrypting a similar puzzle
in C or, worse yet, Perl!
Dr. Gary Herron
> OK. something like
>
> def decrypt(yourstring):
> dedict = {'F': 'S', 'I': 'C', 'H': 'I', 'a': 't', 'c': 'f', 'b': 'v', 'e': 'n',
> 'd': 'o', 'f': 's', 'i': 'c', 'h': 'i', 'k': 'p', 'j': 'h', 'm': 'l',
> 'l': 'j', 'o': 'm', 'q': 'u', 'p': 'w', 's': 'b', 'u': 'z', 't': 'd',
> 'w': 'y', 'v': 'x', 'y': 'e', 'x': 'a', 'z': 'g', 'g': 'k'}
> return "".join([dedict.get(i,i) for i in yourstring])
> returns
...
> It's time to test your brainpower! I will give
> six months of free web hosting to the first person
> to solve this cryptogram. Can you figure it out?
Hi Holger,
Yep, that's it! I figured it would be easy to solve -
especially given the python code, but I didn't expect a
solution THAT quick. Next time I'm using RSA!
> but i don't know if i need free webhosting :-)
Hahaha. Well, if you change your mind, just let me know. :)
C'mon, "the fact that this puzzle was easy to decrypt says" that
"encription" was really trivial. Indeed the most "important" spaces,
and non-alpha characters were not encripted at all. With such
simple encription you'll be able as easily decrypt C and Perl (or
any English text of suffitient length)
Cheers,
Andy.
No problem :-)
Just letting out the python code would make it a bit harder.
One might even have to start to seriously program ...
> > but i don't know if i need free webhosting :-)
>
> Hahaha. Well, if you change your mind, just let me know. :)
cheers,
holger
> > The fact that this puzzle was easy to decrypt says something (good)
> > about Python:
>
> C'mon, "the fact that this puzzle was easy to decrypt says" that
> "encription" was really trivial.
Yes, it was meant to be easy, because it is basically a slightly
disguised SPAM message. There was nothing "pythonic" about this puzzle
at all, except a rather routine piece of code. If I has bothered to
'decrypt' it, I would be pissed. (Reminds me of little Ralphie, in "A
Christmas Story", waiting weeks to get his secret decoder wheel, only
to find the secret message is 'Be sure to drink your Ovaltine')
--
Chad Netzer
cne...@mail.arc.nasa.gov
Trivially easy in fact - since it's just a substitution cypher, you've
already got a lot of information just from the first line of python code -
the first line obviously starts as
import sys
and
cdr kmxhe, irwka he uhk(farhez.myaayrf, ihkjyr):
^^^ ^^
is trivially
for kmxhe, irwka in uhk(farhez.myaayrf, ihkjyr):
^^^ ^^
which gives you a few more letters. In fact, by that stage you already have
12 out of 26 characters.
I suspect it took Holger somewhat less than half an hour to solve ... 5
minutes at most, and most of that is writing the decryption code ;)
Tim Delaney
http://gnosis.cx/download/letterfrequency.gif
lets you start matching letters pretty quickly. Of course, if you don't
know it's English, the frequency table isn't as accurate.
I was thinking of writing a little solver script to actually assign
likely permutations based on the frequencies. But a dozen people had
already solved it before I saw the problem... so I gave up on that :-).
Yours, Lulu...
--
Keeping medicines from the bloodstreams of the sick; food from the bellies of
the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons. Intellectual
property is to the 21st century what the slave trade was to the 16th.
> I suspect it took Holger somewhat less than half an hour to solve ...
> 5
> minutes at most, and most of that is writing the decryption code ;)
It only took two or three minutes for me to solve with an emacs window
open and tr on an interactive shell.
--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Gods are born and die, but the atom endures.
\__/ Alexander Chase
Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html
A new, virtual planet, every day.
> I think the various responders did this "by hand." Probably having
> the
> Python source code made it even easier to just eyeball. In a more
> general sense (just in case anyone doesn't know), the way to solve a
> Caesar cipher like this is to start counting letter frequencies.
> Comparing the frequencies to well-known English letter frequencies
> like:
>
> http://gnosis.cx/download/letterfrequency.gif
>
> lets you start matching letters pretty quickly. Of course, if you
> don't
> know it's English, the frequency table isn't as accurate.
This wouldn't have worked as well here, since the encrypted text was so
short; furthermore, the fact that it was mostly Python code would have
likely skewed the letter frequencies, since Python keywords, modules,
and builtin names appear more frequently in Python code than general
user-chosen identifiers; the letter frequency of the code would be
biased against the letter frequency of the common "words" in Python,
which is likely to be somewhat different from English as a whole.
I wonder about that. Python reserved words (and pseudo-reserved names)
are all rather ordinary English words. I have a hunch that their letter
distribution falls pretty close to that of English prose.
Of course, you'd have to decide how to weight things. If you merely did
a histogram on a list of keywords, you might get a somewhat different
pattern than if you checked actual scripts (with the comments and
variable names removed). For example, most scripts have just a few
'import's at the top, but a whole bunch of 'if's 'for's and 'in's
scattered throughout the body.
Maybe I'll try an experiment.
Yours, Lulu...
--
---[ to our friends at TLAs (spread the word) ]--------------------------
Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego
White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad
---[ Postmodern Enterprises <me...@gnosis.cx> ]--------------------------
Good quote! (Although, unfortunately -- and perhaps more so, if it's a
predictor for "intellectual property" -- slave trade persisted long past the
16th century).
> routine piece of code. If I has bothered to
> 'decrypt' it, I would be pissed. (Reminds me of little Ralphie, in "A
> Christmas Story", waiting weeks to get his secret decoder wheel, only
> to find the secret message is 'Be sure to drink your Ovaltine')
Ha ha ha, love that movie.
"You'll shoot your eye out kid!"
(and I did decrypt it.. not pissed, it was only a 3 minute job)
>>> a = "Hello"
>>> b = [x for x in a]
>>> b
['H', 'e', 'l', 'l', 'o']
>>> "".join(b)
'Hello'
>>>
Thanks !
or
>>> list(a)
['H', 'e', 'l', 'l', 'o']
which is probably faster
> >>> "".join(b)
> 'Hello'