Improved logging output

added unfinished alternative for 2022/2
added docs for 2022/2

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
This commit is contained in:
TuDatTr
2022-12-02 11:51:37 +01:00
parent 8cd8032741
commit 57a95b7c34
8 changed files with 132 additions and 21 deletions

View File

@@ -0,0 +1 @@
/input.txt

View File

@@ -0,0 +1,34 @@
def calc(u1, u2):
if u1 == u2:
print(f'{chr(u1+ord("A")-1)} {chr(u2+ord("X")-1)} draw')
return u2 + 3
elif u1 == (u2 % 3 - 1):
print(f'{chr(u1+ord("A")-1)} {chr(u2+ord("X")-1)} win')
return u2 + 6
else:
print(f'{chr(u1+ord("A")-1)} {chr(u2+ord("X")-1)} loss')
return u2 + 0
def test_2a(file):
res = []
for l in open(file, 'r').read().split('\n'):
if l:
a, b = l.split()
res.append(calc(*(ord(a) - ord("A") + 1, ord(b) - ord("X") + 1)))
res = sum(res)
print(res)
apprehension = task_2a(file)
assert res == apprehension
def task_2a(file):
numify = lambda a_b: (ord(a_b[0]) - ord("A") + 1, ord(a_b[1]) - ord("X") + 1)
return sum([calc(*numify(l.split())) for l in open(file, 'r').read().split('\n') if l])
def task_2b(file):
raise NotImplementedError
if __name__ == '__main__':
print(task_2a('input.txt'))
# print(task_2b('input.txt'))

View File

@@ -0,0 +1,5 @@
Gave up for now, tried to solve the task more or less functionally/mathematically, but it didn't work out.
Related:
- [Calculus on finite weighted graphs](https://en.wikipedia.org/wiki/Calculus_on_finite_weighted_graphs)
- ![notes](whiteboard_notes.jpeg)

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB