diff options
| author | Zach DeCook <zachdecook@librem.one> | 2021-11-24 01:07:04 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2021-11-24 01:19:57 -0500 |
| commit | 85c03d4d69f6a004e3d166680c6163147fb34470 (patch) | |
| tree | 9bd583ae2149f274f9e49bae55642ee10d4388bf /mapScore.py | |
| parent | d7c14388e5eb764056fcf6d3262e2d4028db3e12 (diff) | |
| download | swipeGuess-85c03d4d69f6a004e3d166680c6163147fb34470.tar.gz | |
doc changes, minor fix
Diffstat (limited to 'mapScore.py')
| -rwxr-xr-x | mapScore.py | 17 |
1 files changed, 9 insertions, 8 deletions
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__': |
