This file contains hidden or 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
| use std::io::BufRead; | |
| fn main() { | |
| let reader = std::io::BufReader::new(std::fs::File::open(std::env::args().nth(1).unwrap()).unwrap()); | |
| let mut input = String::new(); | |
| for line in reader.lines() { | |
| for ch in line.unwrap().chars() { | |
| match ch { | |
| '#' => break, | |
| ' ' | '\t' | '\r' | '\n' => (), | |
| c => input.push(c), |
This file contains hidden or 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
| use std::collections::*; | |
| pub fn part1(input: &str) -> usize { | |
| let mut graph = HashMap::new(); | |
| for line in input.lines() { | |
| let mut s = line.split(")"); | |
| let c = s.next().unwrap(); | |
| let o = s.next().unwrap(); |
This file contains hidden or 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 hell import * | |
| y (lambda f: lambda n: | |
| n | |
| (lambda x: lambda x: | |
| f (pred (n)) (lambda x: | |
| and_ (dividesBy (n) (nm(3))) (dividesBy (n) (nm(5))) | |
| (prnts ("FizzBuzz")) | |
| (dividesBy (n) (nm(3)) | |
| (prnts ("Fizz")) |
This file contains hidden or 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
| [package] | |
| name = "bork" | |
| version = "0.1.0" | |
| authors = ["Matthew Tran <[email protected]>"] | |
| edition = "2018" | |
| [dependencies] | |
| # conrod_core = "0.63.0" | |
| # conrod_piston = "0.63.0" | |
| conrod_core = { git = "https://github.com/tdaffin/conrod", branch = "fix_crop" } |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| declare -A small=( | |
| ['W']='ⱽ' | |
| ['A']='ᴬ' | |
| ['B']='ᴮ' | |
| ['D']='ᴰ' | |
| ['E']='ᴱ' | |
| ['G']='ᴳ' | |
| ['H']='ᴴ' |
This file contains hidden or 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
| pub trait TypeName { | |
| const NAME: &'static str; | |
| } | |
| macro_rules! typename { | |
| ($($typ:ty,)*) => { | |
| $(impl TypeName for $typ { | |
| const NAME: &'static str = stringify!($typ); | |
| })* | |
| } |
This file contains hidden or 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
| // 100,000 isn't actually required unless you're trying to compile with relatively large inputs | |
| // such as the input from AoC | |
| #![recursion_limit="100000"] | |
| #![allow(dead_code)] | |
| #![allow(non_camel_case_types)] | |
| /// The General Idea | |
| /// | |
| /// Associated types in traits can be used to make type level functions. A trait of the form shown | |
| /// below can be viewed as a function that takes one type, `Self` and returns a new type, `O`. To |
This file contains hidden or 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
| const OPERATIONS: [fn(usize, usize, usize, usize) -> usize; 16] = [ | |
| |a, ra, b, rb| ra+rb, // addr | |
| |a, ra, b, rb| ra+b, // addi | |
| |a, ra, b, rb| ra*rb, // mulr | |
| |a, ra, b, rb| ra*b, // muli | |
| |a, ra, b, rb| ra & rb, // banr | |
| |a, ra, b, rb| ra & b, // bani | |
| |a, ra, b, rb| ra | rb, // borr | |
| |a, ra, b, rb| ra | b, // bori | |
| |a, ra, _, rb| ra, // setr |
This file contains hidden or 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
| macro_rules! iter { | |
| ($item:expr) => (std::iter::once($item)); | |
| ($item:expr, $($rest:tt)*) => (std::iter::once($item).chain(iter!($($rest)*))); | |
| } | |
| use std::collections::*; | |
| #[derive(PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Hash, Debug)] | |
| enum Unit { | |
| Elf, | |
| Gnome, | |
| } |
This file contains hidden or 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
| fn load(input: &str) -> (isize, isize, Vec<u8>, Vec<(isize, isize, isize, isize, usize)>) { | |
| let width = input.lines().next().unwrap().len() as isize; | |
| let height = input.lines().count() as isize; | |
| let mut matrix = vec![0; (width*height) as usize]; | |
| let mut cars: Vec<(isize, isize, isize, isize, usize)> = vec![]; // (y, x, dx, dy, state) for sorting, down is positive | |
| for (y, line) in input.lines().enumerate() { | |
| for (x, &c) in line.as_bytes().iter().enumerate() { | |
| let x = x as isize; | |
| let y = y as isize; | |
| matrix[(y*width+x) as usize] = c; |