20 lines
411 B
Python
20 lines
411 B
Python
|
import sys
|
||
|
from aoc import nums
|
||
|
|
||
|
MOVES = sorted([(i,j)
|
||
|
for i in range(1,101)
|
||
|
for j in range(1,101)
|
||
|
], key=lambda x:3*x[0]+x[1])
|
||
|
|
||
|
S = 0
|
||
|
for i in sys.stdin.read().strip().split('\n\n'):
|
||
|
[a,b,p] = i.split("\n")
|
||
|
(xa, ya) = nums(a)
|
||
|
(xb, yb) = nums(b)
|
||
|
(xp, yp) = nums(p)
|
||
|
for (i,j) in MOVES:
|
||
|
if xa*i+xb*j==xp and ya*i+yb*j==yp:
|
||
|
S += 3*i+j
|
||
|
break
|
||
|
print(S)
|