Last active
August 29, 2015 14:08
-
-
Save jgc128/5cf29b9112bc29dbdad7 to your computer and use it in GitHub Desktop.
timus
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
#!/usr/bin/python3 | |
from sys import stdin | |
startChar = ord('a') | |
endChar = ord('z') | |
customChars = [['.',',','!'],[' ']] | |
def createCustomCharsTable(): | |
customCharsTable = {} | |
for cList in customChars: | |
for idx, c in enumerate(cList): | |
customCharsTable[c] = idx + 1 | |
return customCharsTable | |
def getCost(char): | |
nc = ord(char) | |
if nc <= endChar and nc >= startChar: | |
cost = (nc - startChar) % 3 + 1 | |
else: | |
cost = customCharsTable[char] | |
return cost | |
customCharsTable = createCustomCharsTable() | |
slogan = stdin.readline()[:-1] # remove \n char at the end of the string | |
costs = [getCost(char) for char in slogan] | |
totalCost = sum(costs) | |
print(totalCost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment