This file contains 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
;/Users/nickb/Downloads/aoc03.prg ==0801== | |
100 rem *** advent of code *** | |
110 rem *** december 3, 2022 *** | |
130 rem | |
140 rem adventofcode.com/2022/day/3 | |
150 rem | |
151 rem by nick bensema | |
152 rem unbibium.github.io |
This file contains 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
#!/usr/bin/env python3 | |
import sys, os,math | |
from collections import deque | |
class Bitstream: | |
def __init__(self, hexstring, length=math.inf): | |
# length only controls when EOF flag is set | |
self.chars = deque(hexstring) |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/15 | |
import sys, os,math | |
from collections import deque | |
class Maze: | |
def __init__(self, lines, size=1): | |
self.size = size |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/14 | |
import sys, os,math | |
from collections import deque, defaultdict | |
def to_pairs(template): | |
result = defaultdict(int) | |
for i in range(len(template)-1): |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/12 | |
import sys, os,math | |
from collections import defaultdict | |
def walk(routes, path, double=None): | |
for dst in routes[path[-1]]: | |
if dst == 'end': |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/7 | |
def pascal(distance): | |
if distance<0: return pascal(-distance) | |
if distance<2: return distance | |
return (distance*(distance+1))//2 | |
def move_all(xs, destination, func=abs): |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/6 | |
from collections import deque | |
class School: | |
def __init__(self, allfish, spawntime=7, firstspawntime=8): | |
if type(allfish) is str: # assume filename | |
with open(allfish) as fi: |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/6 | |
from collections import defaultdict | |
class School: | |
def __init__(self, allfish, spawntime=7, firstspawntime=8): | |
if type(allfish) is str: # assume filename | |
with open(allfish) as fi: |
This file contains 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
#!/usr/bin/env python3 | |
# | |
# https://adventofcode.com/2021/day/5 | |
def walk(start,end): | |
if (start > end): | |
return range(start,end-1,-1) | |
return range(start,end+1) | |
class Segment: |
This file contains 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
#!/usr/bin/env python3 | |
print("22: recursive combat") | |
# I tried to program this without admitting that there | |
# are only two players. | |
import sys, os,math | |
from collections import deque, defaultdict |
NewerOlder