Skip to content

Instantly share code, notes, and snippets.

@ap29600
ap29600 / main.rs
Created December 19, 2022 19:45
Advent of Code day 18 in decent time complexity
use itertools::Itertools;
use std::collections::HashSet;
const N6: [(i64, i64, i64); 6] = [
( 1, 0, 0), (0, 1, 0), (0, 0, 1),
(-1, 0, 0), (0, -1, 0), (0, 0, -1)
];
const N14: [(i64, i64, i64); 18]= [
( 1, 0, 0), (0, 1, 0), ( 0, 0, 1),
(-1, 0, 0), (0, -1, 0), ( 0, 0, -1),
@ap29600
ap29600 / main.rs
Created December 16, 2022 00:13
Advent of Code 2022 day 14 with backtracking
use std::ops::{Index, IndexMut};
use itertools::Itertools;
struct Bitmap {
rows: usize,
cols: usize,
backing: Vec<bool>,
boundary: bool,
}
@ap29600
ap29600 / iterative.odin
Last active December 14, 2021 16:04
Iterative vs recursive solution to AOC 2021 day 12
package aoc12
import "core:fmt"
import "core:slice"
import "core:strings"
when ODIN_DEBUG {
input :: `start-A
start-b
A-c
@ap29600
ap29600 / fish.m
Last active December 9, 2021 11:20
A solution for Advent of Code 2021 day 6 that comfortably fits in a tweet (matlab)
x = sum(load("in.txt")(:) == [0:8])';
A = diag(ones(1, 8), 1);
A(9, 1) = 1;
A(7, 1) = 1;
format rat
sum(A^80*x)
sum(A^256*x)