Created
January 11, 2013 13:47
-
-
Save rennerocha/4510784 to your computer and use it in GitHub Desktop.
This file contains 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
import string | |
def holes(letter): | |
holes_input = string.ascii_letters | |
holes_output = "1101101000000011100000000012010000000000111100000000" | |
holes_table = maketrans(holes_input, holes_output) | |
return int(letter.translate(holes_table)) | |
def count_holes(text): | |
text = text.replace(' ', '') # Ignore spaces | |
return sum([holes(letter) for letter in text]) | |
if __name__ == '__main__': | |
input = 'paralelepipedo' | |
print count_holes(input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment