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::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"); |
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::time::Instant; | |
| use itertools::Itertools; | |
| use rayon::prelude::*; | |
| const INPUT: &str = include_str!("inputs/day08.txt"); | |
| #[derive(Debug, Clone, Copy)] | |
| struct Point { | |
| x: f64, |
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::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() | |
| } |
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::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, |
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::{ | |
| 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) { |
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::{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; | |
| } |
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::{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; |
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::{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], |
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::{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 { |
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::{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 |
NewerOlder