Skip to content

Instantly share code, notes, and snippets.

View joshbduncan's full-sized avatar

Josh Duncan joshbduncan

View GitHub Profile
#!/bin/bash
# https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors
# TEXT COLOR
DEFAULT="\033[0m"
BLACK="\033[30m"
RED="\033[31m"
GREEN="\033[32m"
ORANGE="\033[33m"
# read in aoc input
data = open("day9.in").read().strip().split('\n')
# setup vars to track
pre = 25
pos = 25
# solve for part 1
while True:
p1 = int(data[pos])
from copy import deepcopy
def solve(instructions):
# setup vars to track
acc = 0
pos = 0
visited = set()
# read in aoc input and setup to vars from instructions
time = int(open("day13.in").read().strip().split()[0])
buses = open("day13.in").read().strip().split()[1].split(',')
departures = {}
# part 1
for bus in buses:
if bus != 'x':
bus_id = int(bus)
# calculate closest departure to your time for each bus
# read in aoc input
data = open("day15.in").read().strip().split(',')
def solve(match):
# add starting numbers to dict for tracking
pdict = {}
for i, p in enumerate(data):
pdict[int(p)] = [i + 1]
def solve(match):
pdict = {}
for i, p in enumerate(data):
pdict[int(p)] = i + 1
turn = len(pdict) + 1
same = 0
while turn < match:
def p1(active):
for _ in range(6):
new = set()
xvals = [x[0] for x in active]
yvals = [y[1] for y in active]
zvals = [z[2] for z in active]
for x in range(min(xvals) - 1, max(xvals) + 2):
for y in range(min(yvals) - 1, max(yvals) + 2):
for z in range(min(zvals) - 1, max(zvals) + 2):
def calc1(line):
nums = [int(x) for x in line if x not in ['+', '*']]
ops = [x for x in line if x in ['+', '*']]
total = nums.pop(0)
for n in nums:
if ops == []:
break
else:
total = eval(str(total) + ops.pop(0) + str(n))
def make_banner(txt: str, padding: int = 5, border: str = '*') -> str:
return (
f'{border * (len(txt) + padding * 2)}\n'
f'{" " * padding}{txt}\n'
f'{border * (len(txt) + padding * 2)}'
)
banner = make_banner('Banner as a variable', 4, '#')
print(banner)
import os
import webbrowser
from datetime import datetime
from dotenv import load_dotenv
from todoist.api import TodoistAPI
load_dotenv()
try: