diff options
| author | nekineki <nekineki@nekineki.net> | 2022-12-11 14:47:27 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2022-12-11 14:50:32 +0100 |
| commit | fe75c10e350743a1c078f065d69556fecf825ca5 (patch) | |
| tree | 956556a564c9329346dc9d8b1535dc5e365f3d55 /2022/day02.py | |
| parent | a74d2dc54aef546664bcc8c81eb8e01a93e94391 (diff) | |
move files around, update paths
Diffstat (limited to '2022/day02.py')
| -rwxr-xr-x | 2022/day02.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/2022/day02.py b/2022/day02.py new file mode 100755 index 0000000..b499db3 --- /dev/null +++ b/2022/day02.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 + +import math +import time + +score1 = 0 +score2 = 0 + +# filename = "in/day02.ref" +filename = "in/day02.pzl" +with open(filename) as f: + for line in f: + line = line.strip() + abc, xyz = line[0], line[2] + + if abc == 'A': + abc = 1 + elif abc == 'B': + abc = 2 + elif abc == 'C': + abc = 3 + else: + print('ERROR') + + if xyz == 'X': + xyz = 1 + elif xyz == 'Y': + xyz = 2 + elif xyz == 'Z': + xyz = 3 + else: + print('ERROR') + + s1 = 0 + if abc == xyz: + print('draw') + s1 = 3 + xyz + # elif ((xyz + 1)%3) + 1 == abc: + elif abc%3 + 1 == xyz: + print('win') + s1 = 6 + xyz + else: + print('lose') + s1 = 0 + xyz + print('s1', s1) + score1 += s1 + + if xyz == 1: + # lose + s2 = 0 + (abc-1 + 2)%3 + 1 + elif xyz == 2: + # draw + s2 = 3 + abc + elif xyz == 3: + # win + s2 = 6 + (abc-1 + 1)%3 + 1 + print('s2', s2) + score2 += s2 + + print('score1', score1) + print('score2', score2) + |
