Skip to content

Instantly share code, notes, and snippets.

View sciyoshi's full-sized avatar

Samuel Cormier-Iijima sciyoshi

View GitHub Profile
class a(int):
def __mul__(self, b):
return a(int(self) + b)
def __add__(self, b):
return a(int(self) + b)
def __sub__(self, b):
return a(int(self) * b)
def ev(expr, pt2=False):
expr = re.sub(r"(\d+)", r"a(\1)", expr)
@sciyoshi
sciyoshi / day17.py
Last active December 17, 2020 05:53
import numpy as np
from scipy.ndimage import convolve
LINES = open("inputs/day17").read().splitlines()
dims = 3 # 4 for part 2
steps = 6
front = 2 * steps + 1
filt = np.full((3,) * dims, 1)
filt[(1,) * dims] = 100
tickets = []
rules = {}
valid_range = set()
total = 0
for l in LINES:
if l == "your ticket:" or l == "nearby tickets:":
continue
if ":" in l:
n, rule = l.split(": ")

Keybase proof

I hereby claim:

  • I am sciyoshi on github.
  • I am sciyoshi (https://keybase.io/sciyoshi) on keybase.
  • I have a public key whose fingerprint is 672B C1C9 EBCA 2EF5 C4D5 F0EC 012E AF18 BD36 72DD

To claim this, I am signing this object: