Skip to content

Instantly share code, notes, and snippets.

View nickponline's full-sized avatar
🐙
Computers

Nicholas Pilkington nickponline

🐙
Computers
View GitHub Profile
# https://adventofcode.com/2024/day/23
import networkx as nx, re
graph = nx.Graph()
with open('2024-23.in') as f:
graph.add_edges_from([(source, target) for source, target in re.findall(r'(\w+)-(\w+)', f.read())])
cliques = list(nx.enumerate_all_cliques(graph))
# https://adventofcode.com/2024/day/22
def step(secret):
secret ^= (secret << 0x6) & 0xFFFFFF
secret ^= (secret >> 0x5) & 0xFFFFFF
secret ^= (secret << 0xB) & 0xFFFFFF
return secret
def steps(secret, k=2000):
for _ in range(k):
secret = step(secret)
#https://adventofcode.com/2024/day/21
from functools import cache
import collections
NUM_BOTS = 25
K = collections.defaultdict(list)
K.update({('7', '8'): ['>'], ('7', '4'): ['v'], ('7', '9'): ['>>'], ('7', '5'): ['>v', 'v>'], ('7', '6'): ['>>v', '>v>', 'v>>'], ('7', '1'): ['vv'], ('7', '2'): ['>vv', 'v>v', 'vv>'], ('7', '3'): ['>>vv', '>v>v', 'v>>v', '>vv>', 'v>v>', 'vv>>'], ('7', '0'): ['>vvv', 'v>vv', 'vv>v'], ('7', 'A'): ['>>vvv', '>v>vv', 'v>>vv', '>vv>v', 'v>v>v', 'vv>>v', '>vvv>', 'v>vv>', 'vv>v>'], ('8', '7'): ['<'], ('8', '4'): ['<v', 'v<'], ('8', '9'): ['>'], ('8', '5'): ['v'], ('8', '6'): ['>v', 'v>'], ('8', '1'): ['<vv', 'v<v', 'vv<'], ('8', '2'): ['vv'], ('8', '3'): ['>vv', 'v>v', 'vv>'], ('8', '0'): ['vvv'], ('8', 'A'): ['>vvv', 'v>vv', 'vv>v', 'vvv>'], ('4', '7'): ['^'], ('4', '8'): ['>^', '^>'], ('4', '9'): ['>>^', '>^>', '^>>'], ('4', '5'): ['>'], ('4', '6'): ['>>'], ('4', '1'): ['v'], ('4', '2'): ['>v', 'v>'], ('4', '3'): ['>>v', '>v>', 'v>>'], ('4', '0'): ['>vv', 'v>v'], ('4', 'A'): ['>>vv
@nickponline
nickponline / 2024-21.py
Created December 21, 2024 22:47
Advent of Code 2024 Day 21 Part 1 + Part 2
# https://adventofcode.com/2024/day/21
import networkx as nx
from functools import cache
import collections
# NUM_BOTS = 2
NUM_BOTS = 25
KK = [
['7', '8', '9'],
# A Primel Solver
# Sieve of Eratosthenes
N = 100000
primes = [True] * N
for i in range(2, N):
if not primes[i]:
continue
# Author: Nicholas Pilkington, 2015
# Blog Post: https://nickp.svbtle.com/sudoku-satsolver
import pycosat
N = 9
M = 3
def exactly_one(variables):
cnf = [ variables ]
(gdb) thread apply all bt
Thread 14 (Thread 0x7f89f7067700 (LWP 23443)):
£0 0x00007f89ff922d5c in LZWDecode ()
from /home/ubuntu/tilemill/node_modules/mapnik/lib/binding/libmapnik.so
£1 0x00007f89ff90bffd in TIFFReadEncodedStrip ()
from /home/ubuntu/tilemill/node_modules/mapnik/lib/binding/libmapnik.so
£2 0x00007f89f9534165 in GTiffDataset::LoadBlockBuf(int, int) ()
from /home/ubuntu/tilemill/node_modules/mapnik/lib/binding/mapnik/input/gdal.input
£3 0x00007f89f9536586 in GTiffRasterBand::IReadBlock(int, int, void*) ()
ubuntu@ip-10-182-57-31:~/tilemill$ which node
/usr/bin/node
ubuntu@ip-10-182-57-31:~/tilemill$ gdb /usr/bin/node core
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
// Receive status from drone.
{
source: 'drone',
destination: 'gcs',
name: 'status'
data: {
'mode' : 'manual'
'latitude' : '2324.2434',
'longitude' : '2324.2434',
'altitude' : '2324.2434',
@nickponline
nickponline / install.sh
Created February 11, 2014 00:30
Install TileMill from source with recent GDAL
#!/bin/bash
sudo rm /etc/apt/sources.list.d/*mapnik*
sudo rm /etc/apt/sources.list.d/*developmentseed*
sudo rm /etc/apt/sources.list.d/*chris-lea*
sudo rm /etc/apt/sources.list.d/*ubuntugis*
# Add bleeding edge PPAs
echo 'yes' | sudo apt-add-repository ppa:chris-lea/node.js
echo 'yes' | sudo apt-add-repository ppa:mapnik/v2.2.0