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 / day09.rs
Created December 9, 2025 21:36
Solution for Advent of Code 2025 Day 9
use std::collections::VecDeque;
use std::ops::{Add, Index, IndexMut};
use std::time::Instant;
use itertools::Itertools;
// TODO: There is likely a bug here where we compress boxes of bad space and make it look good. See my drawing.
// NOTE: I often break up impls to make it more understandable of how I went about solving.
const INPUT: &str = include_str!("inputs/day09.txt");
@icub3d
icub3d / day08.rs
Created December 9, 2025 00:25
Solution for Advent of Code 2025 Day 8
use std::time::Instant;
use itertools::Itertools;
use rayon::prelude::*;
const INPUT: &str = include_str!("inputs/day08.txt");
#[derive(Debug, Clone, Copy)]
struct Point {
x: f64,
@icub3d
icub3d / day07.rs
Created December 7, 2025 21:46
Solution for Advent of Code 2025 Day 7
use std::time::Instant;
use rustc_hash::{FxHashMap, FxHashSet};
const INPUT: &[u8] = include_bytes!("inputs/day07.txt");
const INPUT_STR: &str = include_str!("inputs/day07.txt");
fn parse(input: &str) -> Vec<Vec<char>> {
input.lines().map(|l| l.chars().collect()).collect()
}
@icub3d
icub3d / day06.rs
Created December 6, 2025 20:17
Solution for Advent of Code 2025 Day 6
use std::time::Instant;
// TODO we could read numbers from the right hand side of the "grid" and when we get an operator, we simply perform that operation on the stack of numbers and then add it to our total.
// This would involve p1 being different. We just have a vec of iterators of all the "numbers" and "operators" and solve one column at a time.
const INPUT: &[u8] = include_bytes!("inputs/day06.txt");
#[derive(Debug)]
enum Operator {
Add,
@icub3d
icub3d / nastyhacks.rs
Created December 5, 2025 19:43
Kattis nastyhacks
use std::{
cmp::Ordering,
io::{Read, stdin},
};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1) {
@icub3d
icub3d / leftbeehind.rs
Created December 5, 2025 19:43
Kattis leftbeehind
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines() {
if m == "0 0" {
break;
}
@icub3d
icub3d / helpaphd.rs
Created December 5, 2025 19:43
Kattis helpaphd
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1) {
if m == "P=NP" {
println!("skipped");
continue;
@icub3d
icub3d / eligibility.rs
Created December 5, 2025 19:43
Kattis eligibility
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1) {
let pp = m.split_whitespace().collect::<Vec<_>>();
let (name, studies, dob, courses) = (
pp[0],
@icub3d
icub3d / oddities.rs
Created December 5, 2025 19:43
Kattis oddities
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1).map(|l| l.parse::<isize>().unwrap()) {
if m % 2 == 0 {
println!("{m} is even");
} else {
@icub3d
icub3d / temperature.rs
Created December 5, 2025 19:43
Kattis temperature
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let (x, y) = s.trim().split_once(' ').unwrap();
let (x, y) = (x.parse::<f32>().unwrap(), y.parse::<f32>().unwrap());
// n = n*y + x
// 0 = yn - n + x