Last active
December 6, 2021 08:05
-
-
Save 0e4ef622/7b75afe0597e6902682f01da356e9bcf to your computer and use it in GitHub Desktop.
AoC 2021 Day 6 in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
r0 = 1.0910244704807567604 | |
c1 = 0.823167270149155 | |
c2 = 0.0445506192519361 | |
c3 = 0.0640519155651715 | |
c4 = 0.146739953698779 | |
c5 = -0.0884627271380199 | |
c6 = -0.268850251751933 | |
c7 = -0.0370225624840499 | |
c8 = 0.0608331591105281 | |
c9 = 0.238266103907743 | |
d1 = -1.0800117522242578 | |
d2 = -0.9700688405618049 | |
d3 = 0.8754511570117521 | |
d4 = 1.0438060194527128 | |
a1 = -0.39672051056790375 | |
a2 = -1.1691713774016088 | |
a3 = 1.461199774043809 | |
a4 = 0.7908089843277325 | |
def f(n): | |
return (c1*r0**n + | |
c2*d1**n*math.sin(n*a1) + c3*d1**n*math.cos(n*a1) + | |
c4*d2**n*math.sin(n*a2) + c5*d2**n*math.cos(n*a2) + | |
c6*d3**n*math.sin(n*a3) + c7*d3**n*math.cos(n*a3) + | |
c8*d4**n*math.sin(n*a4) + c9*d4**n*math.cos(n*a4)) | |
*n, = map(int, input().split(',')) | |
p1 = 0 | |
p2 = 0 | |
for v in n: | |
p1 += f(80 + 6 - v) | |
p2 += f(256 + 6 - v) | |
print(round(p1)) | |
print(round(p2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment