#!/usr/bin/python # lily0.py - Don Yang (uguu.org) # # 12/21/08 # 33 .. 38 = newline # 40 .. 91 = char # 93 .. 126 = space template = "AaAa!" code = "1234567890" * 1000 # Expand template to a flat string expanded_template = "".join([ [ "\n", "X" * (ord(i) - ord("(") + 1), " " * (ord(i) - ord("]") + 1) ][int((ord(i) + 13) / 53)] for i in template ]) # Count number of non-whitespace characters char_count = lambda str: len( filter(lambda i: not i.isspace(), iter(str)) ) # Count number of non-whitespace characters in template up to a # particular offset partial_char_count = lambda pos: char_count(expanded_template[0 : pos + 1]) # Merge template with input code text = "".join([ [ code[partial_char_count(index) - 1], expanded_template[index] ][expanded_template[index].isspace()] for index in range(len(expanded_template)) ]) print text