Skip to content

Instantly share code, notes, and snippets.

@snoyes
snoyes / aoc2025-d04.py
Created December 4, 2025 16:22
Advent of Code 2025 day 4 with no IF, AND, or OR.
from collections import Counter
from itertools import takewhile, count
def playLife(layout, cycles):
previous = None
living = {(x, y) for x, line in enumerate(layout) for y, _ in filter(lambda c: c[1] == '@', enumerate(line))}
has_changed = takewhile(lambda _: living != previous, count())
getNeighbors = lambda cell: {(cell[0] + x, cell[1] + y) for x in range(-1, 2) for y in range(-1, 2)}
for _ in zip(range(cycles), has_changed):
previous = living
@snoyes
snoyes / aoc2025-d01.rock
Created December 1, 2025 21:42
Advent of Code 2025 Day 01 in Rockstar
let thought be like truth vaccinated
let wit be like jackanapes
let the truth be wit
let the dream be wit
listen to the stream
until the stream is nothing,
roll it into the abyss.
let the day be the abyss between "R" of 2 without 1
cast the stream with 10
let the memory be thought;
@snoyes
snoyes / gist:0fd970a1c0fea3975b67057ef2f94821
Created March 21, 2023 20:18
show only those tags which are N0, N1, N2, etc.
{{Front}}
<div id='tags'>{{Tags}}</div>
<script>
let tags = document.getElementById('tags')
tags.innerHTML = tags.innerHTML.split(' ').filter(function(tag){return tag.match(/^N[0-9]$/i)}).join(' ');
</script>
DROP TABLE IF EXISTS day15;
CREATE TABLE `day15` (
`signalX` int DEFAULT NULL,
`signalY` int DEFAULT NULL,
`beaconX` int DEFAULT NULL,
`beaconY` int DEFAULT NULL,
`radius` int GENERATED ALWAYS AS (ABS(`signalX` - `beaconX`) + ABS(`signalY` - `beaconY`))
);
LOAD DATA INFILE 'c:/ProgramData/MySQL/MySQL Server 8.0/Uploads/day15.txt' INTO TABLE day15
@snoyes
snoyes / day12.sql
Created December 12, 2022 21:46
In MySQL. Not setting any speed records, and some of this syntax is deprecated.
DROP TABLE IF EXISTS day12, graph;
SET NAMES binary;
CREATE TABLE day12 (
rowNum int DEFAULT 1,
colNum int auto_increment,
cell char(1),
primary key (rowNum, colNum)
) DEFAULT CHARSET=binary ENGINE=MyISAM;
CREATE TABLE day09 (
direction ENUM('U', 'D', 'L', 'R'),
distance int
) ENGINE=BLACKHOLE;
CREATE TABLE knots (
id int primary key,
x int,
y int
);
@snoyes
snoyes / day07.sql
Created December 7, 2022 22:05
MySQL solution to AoC 2022 Day 7
CREATE TABLE `day07` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`parentId` int unsigned DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`size` int unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TRIGGER `day07_bi` BEFORE INSERT ON `day07` FOR EACH ROW SET NEW.parentId = @curdir;
@snoyes
snoyes / aoc_2022_day01.sql
Created December 2, 2022 14:30
Advent of Code, day 1, in pure MySQL
CREATE TABLE day01 (elf int auto_increment primary key, calories JSON);
LOAD DATA LOCAL INFILE 'day01.txt' INTO TABLE day01
LINES TERMINATED BY '\n\n' (@cal)
SET calories = CONCAT('[', TRIM(TRAILING ',' FROM REPLACE(@cal, '\n', ',')), ']');
CREATE VIEW calories AS SELECT SUM(cal) AS cal
FROM day01
JOIN JSON_TABLE(calories, '$[*]' COLUMNS(cal int path '$')) jt GROUP BY elf ORDER BY cal DESC;
@snoyes
snoyes / update field.py
Last active September 10, 2023 14:20
Anki: move part of field to different field, or remove unwanted content from a field
# Open the debug console with Ctrl+: (which is Ctrl+Shift+; on US keyboards)
# (Don't have the browser window open when you do.)
# Run it with Ctrl+Enter
# Remove the # from the last line to actually save the changes
s = r'regular expression to search for goes here'
srcField = 'Source Field Name goes here'
tgtField = 'Target Field Name goes here'
noteType = 'Name of the Note Type goes here'