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 / day03.rs
Created January 17, 2026 22:55
Solution for Advent of Code 2017 Day 3
use std::time::Instant;
use itertools::Itertools;
use rustc_hash::FxHashMap;
const INPUT: &str = include_str!("inputs/day03.txt");
fn parse(input: &str) -> usize {
input.trim().parse::<usize>().unwrap()
}
@icub3d
icub3d / day02.rs
Created January 17, 2026 22:52
Solution for Advent of Code 2017 Day 2
use std::time::Instant;
const INPUT: &str = include_str!("inputs/day02.txt");
fn parse(input: &str) -> impl Iterator<Item = &str> {
input.trim().lines()
}
fn p1(input: &str) -> usize {
parse(input)
@icub3d
icub3d / day01.rs
Created January 17, 2026 22:50
Solution for Advent of Code 2017 Day 1
use std::time::Instant;
const INPUT: &str = include_str!("inputs/day01.txt");
fn parse(input: &str) -> impl Iterator<Item = u32> {
input.trim().chars().map(|c| c.to_digit(10).unwrap())
}
fn p1(input: &str) -> u32 {
let input = parse(input).collect::<Vec<_>>();
@icub3d
icub3d / yinyangstones.rs
Created January 12, 2026 19:58
Kattis yinyangstones
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
// Both operations are opposites, just count.
let (b, w) = s.trim().chars().fold((0, 0), |(b, w), c| match c {
'B' => (b + 1, w),
_ => (b, w + 1),
@icub3d
icub3d / volim.rs
Created January 12, 2026 19:58
Kattis volim
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut ss = s.lines();
let mut cur = ss.next().unwrap().parse::<isize>().unwrap();
ss.next();
@icub3d
icub3d / sevenwonders.rs
Created January 12, 2026 19:58
Kattis sevenwonders
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut counts = [0; 3];
for c in s.trim().chars() {
match c {
'T' => counts[0] += 1,
@icub3d
icub3d / ptice.rs
Created January 12, 2026 19:58
Kattis ptice
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let quiz = s.lines().nth(1).unwrap();
let patterns = [("Adrian", "ABC"), ("Bruno", "BABC"), ("Goran", "CCAABB")];
@icub3d
icub3d / mosquito.rs
Created January 12, 2026 19:58
Kattis mosquito
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
// $M$ , $P$ , $L$ , $E$ , $R$ , $S$ , $N$
for m in s.lines() {
let mut pp = m.split_whitespace().map(|l| l.parse::<usize>().unwrap());
let (mut m, mut p, mut l, e, r, s, n) = (
@icub3d
icub3d / drinkingsong.rs
Created January 12, 2026 19:58
Kattis drinkingsong
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut ss = s.lines();
let n = ss.next().unwrap().parse::<usize>().unwrap();
let d = ss.next().unwrap();
@icub3d
icub3d / bubbletea.rs
Created January 12, 2026 19:58
Kattis bubbletea
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut ss = s.lines();
ss.next();
let teas = ss