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
| #!/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" |
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
| # 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]) |
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
| from copy import deepcopy | |
| def solve(instructions): | |
| # setup vars to track | |
| acc = 0 | |
| pos = 0 | |
| visited = set() |
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
| # 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 |
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
| # 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] |
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
| def solve(match): | |
| pdict = {} | |
| for i, p in enumerate(data): | |
| pdict[int(p)] = i + 1 | |
| turn = len(pdict) + 1 | |
| same = 0 | |
| while turn < match: |
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
| 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): |
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
| 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)) |
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 os | |
| import webbrowser | |
| from datetime import datetime | |
| from dotenv import load_dotenv | |
| from todoist.api import TodoistAPI | |
| load_dotenv() | |
| try: |
OlderNewer