Skip to content

Instantly share code, notes, and snippets.

@rabuf
rabuf / day17.py
Created December 17, 2022 17:38
Using a generator for tetris pieces
pieces = [{3,4,5,6},
{4, 3+1j, 4+1j, 5+1j, 4+2j},
{3, 4, 5, 5+1j, 5+2j},
{3, 3+1j, 3+2j, 3+3j},
{3, 4, 3+1j, 4+1j}]
def make_piece():
level = 0
for piece in cycle(pieces):
@rabuf
rabuf / day08.rs
Created December 9, 2021 22:37
Present version of AoC2021 Day 08, not at all optimal
use itertools::Itertools;
use lazy_static::lazy_static;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn get_input(filename: &str) -> (Vec<Vec<String>>, Vec<Vec<String>>) {
let file = File::open(filename).unwrap();
let lines = BufReader::new(file).lines();
let mut displays = vec![];

Keybase proof

I hereby claim:

  • I am rabuf on github.
  • I am jtsummers (https://keybase.io/jtsummers) on keybase.
  • I have a public key ASDPgB1khrqckkW16UTuQRPml00Lc9i3K3bHr8UrdspjWgo

To claim this, I am signing this object:

# 1 2 3 5 8 10 11
Q = [0, 1/3, 1/3, 1/3, 0, 0, 0; #1
0, 0, 1/3, 2/3, 0, 0, 0; #2
0, 0, 0, 2/3, 0, 0, 1/3; #3
0, 1/3, 0, 0, 1/3, 0, 1/3; #5
0, 0, 0, 0, 1/3, 1/3, 1/3; #8
0, 0, 0, 0, 0, 0, 1/3; #10
0, 0, 0, 0, 0, 0, 0] #11
N = (eye(7) - Q) ^ - 1
@rabuf
rabuf / test_framework.sml
Created October 29, 2013 03:47
This is the test framework I put together for the SML portion of the Coursera class "Programming Languages", taught by Dan Grossman. I preferred this format to a series of dozens of assignments like `val test<n> = <some function call> = <some result>`
(* Test framework, since we only submit 2 files I'm copy/pasting this here *)
datatype (''a,''b) testcase =
TestCase of ''a * ''b * string
| TestCaseException of ''a * exn * string
datatype 'a testresult = Pass | Fail of 'a
datatype ('a,'b,'c) test = Test of 'c * ('a,'b) testcase list
fun test (Test (f,cases)) =
let fun aux cases acc =
case cases of