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 |
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(); | |
| let mut s = s.lines(); |
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::{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() |
NewerOlder