aoc2017day02-2

Run Settings
LanguagePython
Language Version
Run Command
import sys def doit(input): rows = input.strip().split("\n") sum = 0 for r in rows: vals = list(map(int,r.strip().split())) for i in range(len(vals)): for j in range(len(vals)): if j <= i: continue if vals[i] % vals[j] == 0: #print(vals[i], vals[j]) sum += int(vals[i] / vals[j]) if vals[j] % vals[i] == 0: #print(vals[j], vals[i]) sum += int(vals[j] / vals[i]) return "%d" % sum input = sys.stdin.read() print(doit(input))
Editor Settings
Theme
Key bindings
Full width
Lines