Skip to content

Instantly share code, notes, and snippets.

@adrian17
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrian17/554d75d556001929715e to your computer and use it in GitHub Desktop.
Save adrian17/554d75d556001929715e to your computer and use it in GitHub Desktop.
numbers_cleanup
#Ugly but working
dataz="""\
_ _ _ _ _ _ _ _ _
| || || || || || || || || |
|_||_||_||_||_||_||_||_||_|
| | | | | | | | |
| | | | | | | | |
_ _ _ _ _ _ _
|_||_|| || ||_ | | ||_
| _||_||_||_| | | | _|
"""
display = """\
_ _ _ _ _ _ _ _
| | | _| _||_||_ |_ ||_||_|
|_| ||_ _| | _||_| ||_| _|
"""
display, dataz = display.splitlines(), [line.ljust(27) for line in dataz.splitlines()] #Preprocess Input
lookup = {}
for i in range(10):
lookup[''.join(line[i*3:i*3+3] for line in display)] = str(i) #Create lookup table
for i in range(0, len(dataz), 4): #For each input line
line = ''
for j in range(0, len(dataz[i]), 3): #For each character
identifier = ''.join([dataz[k][l] for k in range(i, i+3) for l in range(j, j+3)]) #Slice out the identifier
line += lookup[identifier] #Look up number
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment