aoc2017day03

Run Settings
LanguagePython
Language Version
Run Command
import sys import math def doit(input): val = int(input) i_ = int((math.sqrt(val-1) - 1) / 2) di = 8 * (i_ + 1) si_ = (2 * i_ + 1)**2 d = (val - si_) % (di/4) li = (2*(i_+1) + 1) x = i_ + 1 y = int(math.fabs(d - (i_+ 1))) dist = x + y return "%d" % dist input = sys.stdin.read() print(doit(input))
Editor Settings
Theme
Key bindings
Full width
Lines