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 / 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
@icub3d
icub3d / quadrant.rs
Created December 5, 2025 19:43
Kattis quadrant
use std::{
cmp::Ordering,
io::{Read, stdin},
};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut s = s.lines();
@icub3d
icub3d / day05.rs
Created December 5, 2025 15:59
Solution for Advent of Code 2025 Day 5
use std::{ops::RangeInclusive, time::Instant};
const INPUT: &str = include_str!("inputs/day05.txt");
fn parse(input: &str) -> (Vec<RangeInclusive<usize>>, impl Iterator<Item = usize>) {
let (ranges, ingredients) = input.split_once("\n\n").unwrap();
// Collect our ranges.
let ranges = ranges
.lines()
@icub3d
icub3d / day04.rs
Created December 4, 2025 18:44
Solution for Advent of Code 2025 Day 4
use std::time::Instant;
use itertools::Itertools;
use rustc_hash::FxHashSet;
const INPUT: &str = include_str!("inputs/day04.txt");
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
struct Point {
row: isize,
@icub3d
icub3d / day03.rs
Created December 4, 2025 01:17
Solution for Advent of Code 2025 Day 3
use std::time::Instant;
const INPUT: &str = include_str!("inputs/day03.txt");
fn parse(input: &str) -> impl Iterator<Item = Vec<usize>> {
// Turn each line into a list of digits.
input.lines().map(|l| {
l.chars()
.map(|c| c.to_digit(10).unwrap() as usize)
.collect()
@icub3d
icub3d / day02.rs
Created December 2, 2025 18:40
Solution for Advent of Code 2025 Day 2
use rayon::prelude::*;
use std::{ops::RangeInclusive, time::Instant};
const INPUT: &str = include_str!("inputs/day02.txt");
fn parse(input: &str) -> impl Iterator<Item = RangeInclusive<usize>> {
// Convert the input into a list of ranges.
input.trim().split(',').map(|l| {
l.split_once('-')
.map(|(l, r)| l.parse().unwrap()..=r.parse().unwrap())
@icub3d
icub3d / day01.rs
Created December 1, 2025 21:32
Solution for Advent of Code 2025 Day 1
use std::time::Instant;
const INPUT: &str = include_str!("inputs/day01.txt");
fn parse(input: &'_ str) -> impl Iterator<Item = (char, isize)> {
input.lines().map(|l| {
let mut chars = l.chars();
(
chars.next().unwrap(),
chars.as_str().parse::<isize>().unwrap(),
@icub3d
icub3d / tarifa.rs
Created November 30, 2025 02:01
Kattis tarifa
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let mut s = s.lines();
let x = s.next().map(|l| l.parse::<usize>().unwrap()).unwrap();
@icub3d
icub3d / qaly.rs
Created November 30, 2025 02:01
Kattis qaly
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
let q = s
.lines()
.skip(1)
.map(|l| {