Skip to content

Instantly share code, notes, and snippets.

View icub3d's full-sized avatar

Joshua Marsh icub3d

  • Optum
  • USA
View GitHub Profile
@icub3d
icub3d / main.rs
Created December 23, 2023 18:19
Advent of Code 2023 - Day 23
use colored::Colorize;
use std::{
collections::{HashMap, HashSet, VecDeque},
ops::Add,
};
// We'll use a point to track where each position is on the map.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
struct Point {
@icub3d
icub3d / main.rs
Last active December 30, 2023 16:36
Advent of Code 2023 - Day 22
use std::{
cell::RefCell,
collections::{HashMap, HashSet, VecDeque},
rc::Rc,
};
// Point is used to track the start and end of a block.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
struct Point {
x: usize,
@icub3d
icub3d / main.rs
Created December 22, 2023 00:54
Advent of Code 2023 - Day 21
use std::{
collections::{HashMap, HashSet, VecDeque},
ops::Add,
};
// Standard point in the garden.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
struct Point {
x: i32,
y: i32,
@icub3d
icub3d / main.rs
Created December 20, 2023 19:48
Advent of Code 2023 - Day 20
use std::collections::{HashMap, HashSet, VecDeque};
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
enum Pulse {
High,
Low,
}
// A communication is a pulse from one module to another.
#[derive(Debug, Eq, PartialEq, Clone)]
@icub3d
icub3d / main.rs
Created December 19, 2023 21:51
Advent of Code 2023 - Day 19
use std::collections::HashMap;
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{alpha1, digit1, one_of},
combinator::map,
multi::separated_list1,
sequence::tuple,
IResult,
@icub3d
icub3d / main.rs
Created December 18, 2023 20:41
Advent of Code 2023 - Day 18
use std::collections::HashSet;
use nom::{
bytes::complete::tag,
character::complete::{alphanumeric1, digit1, one_of, space1},
sequence::tuple,
IResult,
};
#[derive(Debug)]
@icub3d
icub3d / main.rs
Last active January 2, 2024 20:13
Advent of Code 2023 - Day 17
use std::collections::{BinaryHeap, HashMap};
// We need to track the direction we're coming from to make sure we
// don't go further in one direction than we're allowed.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
enum Direction {
North,
South,
East,
West,
@icub3d
icub3d / main.rs
Created December 16, 2023 17:52
Advent of Code 2023 - Day 16
use std::{
collections::{HashSet, VecDeque},
ops::Add,
};
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
enum Direction {
Up,
Down,
Left,
@icub3d
icub3d / main.rs
Created December 15, 2023 18:56
Advent of Code 2023 - Day 15
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{alpha1, digit1},
combinator::map,
multi::separated_list1,
sequence::preceded,
IResult,
};
@icub3d
icub3d / main.rs
Last active December 27, 2023 22:21
Advent of Code 2023 - Day 14
use std::{collections::HashSet, hash::Hasher};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct Grid {
grid: Vec<Vec<char>>,
}
impl Grid {
fn parse(input: &str) -> Self {
let grid = input