w[ben@roflcopter xchatlogs]$ python
s =Python 2.7.2 (default, Mar 11 2012, 15:20:40)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "01000110011000010110111001110100011000010111001101110100011010010110001"
>>> s.split()
['010001100110000101101110011101000110000101110011011101000110100101100011']
>>> s.split("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: empty separator
>>> s[::8]
'000000000'
>>> v = [s[i::8] for i in xrange(8)]
>>> v
['000000000', '111111111', '011111111', '000101100', '001000010', '101100100', '101001001', '010011011']
>>> v = [[z for z in s[i::8]] for i in xrange(8)]
>>> v
[['0', '0', '0', '0', '0', '0', '0', '0', '0'], ['1', '1', '1', '1', '1', '1', '1', '1', '1'], ['0', '1', '1', '1', '1', '1', '1', '1', '1'], ['0', '0', '0', '1', '0', '1', '1', '0', '0'], ['0', '0', '1', '0', '0', '0', '0', '1', '0'], ['1', '0', '1', '1', '0', '0', '1', '0', '0'], ['1', '0', '1', '0', '0', '1', '0', '0', '1'], ['0', '1', '0', '0', '1', '1', '0', '1', '1']]
>>> zip(v)
[(['0', '0', '0', '0', '0', '0', '0', '0', '0'],), (['1', '1', '1', '1', '1', '1', '1', '1', '1'],), (['0', '1', '1', '1', '1', '1', '1', '1', '1'],), (['0', '0', '0', '1', '0', '1', '1', '0', '0'],), (['0', '0', '1', '0', '0', '0', '0', '1', '0'],), (['1', '0', '1', '1', '0', '0', '1', '0', '0'],), (['1', '0', '1', '0', '0', '1', '0', '0', '1'],), (['0', '1', '0', '0', '1', '1', '0', '1', '1'],)]
>>> zip(*v)
[('0', '1', '0', '0', '0', '1', '1', '0'), ('0', '1', '1', '0', '0', '0', '0', '1'), ('0', '1', '1', '0', '1', '1', '1', '0'), ('0', '1', '1', '1', '0', '1', '0', '0'), ('0', '1', '1', '0', '0', '0', '0', '1'), ('0', '1', '1', '1', '0', '0', '1', '1'), ('0', '1', '1', '1', '0', '1', '0', '0'), ('0', '1', '1', '0', '1', '0', '0', '1'), ('0', '1', '1', '0', '0', '0', '1', '1')]
>>> x = [l.join for l in zip(*v)]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'join'
>>> x = [''.join(l) for l in zip(*v)]
>>> x
['01000110', '01100001', '01101110', '01110100', '01100001', '01110011', '01110100', '01101001', '01100011']
>>> [str("0b"+r) for r in x]
['0b01000110', '0b01100001', '0b01101110', '0b01110100', '0b01100001', '0b01110011', '0b01110100', '0b01101001', '0b01100011']
>>> [eval("0b"+r) for r in x]
[70, 97, 110, 116, 97, 115, 116, 105, 99]
>>> [chr(eval("0b"+r)) for r in x]
['F', 'a', 'n', 't', 'a', 's', 't', 'i', 'c']
>>>
f = lambda s : ''.join([chr(eval("0b"+r)) for r in [''.join(l) for l in zip(*[s[i::8] for i in xrange(8)])]])
nimdahk wrote:nalyd8991 wrote:Aw man, rubberbanding saves my life every time I play hallway.
By preventing you from meeting anyone?
Return to Ace of Spades Discussion
Users browsing this forum: No registered users and 1 guest