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
<html> | |
<head> | |
<title>Flask Search Token Highlighter Javascript</title> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"> | |
<style> | |
.quote-list {max-width: 42em; padding-top: 3em;} | |
</style> | |
</head> |
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
// get the two tables I need to work on | |
let jobsTable = base.getTable("Jobs"); | |
let timeEntriesTable = base.getTable("Time Entries"); | |
// get all time entries for later reference | |
let timeEntriesQuery = await timeEntriesTable.selectRecordsAsync(); | |
// when run via button, automatically use that record otherwise choose | |
let record = await input.recordAsync('Choose a record', jobsTable); | |
// get all linked time entries for record | |
let linkedTimeEntries = record.getCellValue("Time Entries") || []; | |
output.text("Found " + linkedTimeEntries.length + " total time entries"); |
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
import heapq | |
from collections import defaultdict | |
def solve(tiles): | |
rows, cols = size_y * tiles, size_x * tiles | |
costs = defaultdict(int) | |
pqueue = [(0, 0, 0)] | |
heapq.heapify(pqueue) |
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
from collections import defaultdict | |
data = open("day17.in").read().strip() | |
x_range, y_range = data.split(": ")[1].split(", ") | |
x_lower, x_upper = x_range.split("=")[1].split("..") | |
x_lower, x_upper = int(x_lower), int(x_upper) | |
y_lower, y_upper = y_range.split("=")[1].split("..") | |
y_lower, y_upper = int(y_lower), int(y_upper) |
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
from collections import defaultdict | |
def parse(data): | |
scanners = [] | |
for scanner in data: | |
beacons = [] | |
for line in scanner.split("\n"): | |
if "--" not in line: | |
beacons.append(tuple([int(c) for c in line.split(",")])) |
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
import functools | |
import itertools | |
data = open("day21.in").read().strip().split("\n") | |
# part 1 | |
p1, p2 = int(data[0][-1]), int(data[1][-1]) | |
s1 = s2 = 0 | |
die = rolls = 0 |
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
from collections import defaultdict | |
def cube_vol(b): | |
x1, x2 = b[0] | |
y1, y2 = b[1] | |
z1, z2 = b[2] | |
return (abs(x2 - x1) + 1) * (abs(y2 - y1) + 1) * (abs(z2 - z1) + 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
import itertools | |
import math | |
import re | |
def add(data): | |
if " + " in data: | |
data = f"[{data.split(' + ')[0]},{data.split(' + ')[1]}]" | |
return data |
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
import sys | |
import time | |
def spinner(msg="working..."): | |
i = 0 | |
ticks = ["-", "\\", "|", "/"] | |
try: | |
while True: | |
tick = ticks[i % len(ticks)] |
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
import sys | |
import time | |
from contextlib import contextmanager | |
def spinner_indicator(msg): | |
ticks = ["-", "\\", "|", "/"] | |
i = 0 | |
while True: | |
tick = ticks[i % len(ticks)] |