[Verba] Re: Nemesis Coding Solution
Stuart D. Gathman
stuart at gathman.org
Mon Jan 23 01:19:54 EST 2006
> There are 10 kinds of people in the world: those who understand
> binary, and those who don't.
Here is my solution:
(Requires python2.4 - needs extra brackets for python2.3)
def decode(c):
"""Decode binary strings to ASCII
>>> decode('010000100110100101101110011000010111001001111001')
'Binary'
"""
c = ''.join(c.split()) # remove whitespace
return ''.join(chr(int(c[i:i+8],2)) for i in range(0,len(c),8))
# Make into a program that can decode a message from stdin:
import sys
print decode(sys.stdin.read())
--
Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
More information about the Verba
mailing list