Last active
August 29, 2015 14:14
-
-
Save adrian17/554d75d556001929715e to your computer and use it in GitHub Desktop.
numbers_cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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