From 85c03d4d69f6a004e3d166680c6163147fb34470 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 24 Nov 2021 01:07:04 -0500 Subject: doc changes, minor fix --- mapScore.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'mapScore.py') diff --git a/mapScore.py b/mapScore.py index 2385106..61a5259 100755 --- a/mapScore.py +++ b/mapScore.py @@ -17,23 +17,24 @@ def makeMap(filename): break return l -def scoreWord(word,mmap): - pc=word[0] +def scoreWord(word,mm): + pc=word[0] or ' ' s=0 for c in word: #manhattan dist - s+=abs(mmap[ord(pc)][0]-mmap[ord(c)][0]) - s+=abs(mmap[ord(pc)][1]-mmap[ord(c)][1]) + s+=abs(mm[ord(pc)][0]-mm[ord(c)][0]) + s+=abs(mm[ord(pc)][1]-mm[ord(c)][1]) pc=c return s def main(argv): mm=makeMap(argv[1]) while 1: - line = sys.stdin.readline() - if not line: - break - w=line.strip() + line = sys.stdin.readline() + if not line: + break + w=line.strip() + if w: print(scoreWord(w,mm),w,sep='\t') if __name__ == '__main__': -- cgit 1.4.1