From 8c3c7a06731d43b9051640cc20a40d988ba9ed72 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 24 Nov 2021 00:30:20 -0500 Subject: mapscore: calculate score --- mapScore.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mapScore.py') diff --git a/mapScore.py b/mapScore.py index 1a8dfa9..4f69847 100755 --- a/mapScore.py +++ b/mapScore.py @@ -17,9 +17,20 @@ def makeMap(filename): break return l +def scoreWord(word,mmap): + pc=word[0] + 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]) + pc=c + return s + + def main(argv): - import json - json.dump(makeMap(argv[1]),sys.stdout) + mmap=makeMap(argv[1]) + print(scoreWord('ads',mmap)) if __name__ == '__main__': main(sys.argv) -- cgit 1.4.1