Smithy Code

Fredrik Lundh | April 2006 | Originally posted to

$ more

from string import uppercase as alphabet
from itertools import izip, cycle
import sys


def fib(n): # from the python tutorial
    a, b = 0, 1
    while b < n:
        yield b
        a, b = b, a+b

def decode(code):
    for c, d in izip(code, cycle(fib(len(alphabet)))):
        yield alphabet[(alphabet.index(c) + d - 1) % len(alphabet)]


$ python

A Django site. rendered by a django application. hosted by webfaction.