Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
def m2f_e(s, st):
|
||||
return [[st.index(ch), st.insert(0, st.pop(st.index(ch)))][0] for ch in s]
|
||||
|
||||
def m2f_d(sq, st):
|
||||
return ''.join([st[i], st.insert(0, st.pop(i))][0] for i in sq)
|
||||
|
||||
ST = list('abcdefghijklmnopqrstuvwxyz')
|
||||
for s in ['broood', 'bananaaa', 'hiphophiphop']:
|
||||
encode = m2f_e(s, ST[::])
|
||||
print('%14r encodes to %r' % (s, encode), end=', ')
|
||||
decode = m2f_d(encode, ST[::])
|
||||
print('decodes back to %r' % decode)
|
||||
assert s == decode, 'Whoops!'
|
||||
Loading…
Add table
Add a link
Reference in a new issue