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 rustc_hash::FxHashMap; | |
| const INPUT: &str = include_str!("inputs/day03.txt"); | |
| fn parse(input: &str) -> usize { | |
| input.trim().parse::<usize>().unwrap() | |
| } |
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; | |
| 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) |
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; | |
| 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<_>>(); |
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(); | |
| // 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), |
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 mut ss = s.lines(); | |
| let mut cur = ss.next().unwrap().parse::<isize>().unwrap(); | |
| ss.next(); |
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 mut counts = [0; 3]; | |
| for c in s.trim().chars() { | |
| match c { | |
| 'T' => counts[0] += 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(); | |
| let quiz = s.lines().nth(1).unwrap(); | |
| let patterns = [("Adrian", "ABC"), ("Bruno", "BABC"), ("Goran", "CCAABB")]; |
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(); | |
| // $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) = ( |
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 mut ss = s.lines(); | |
| let n = ss.next().unwrap().parse::<usize>().unwrap(); | |
| let d = ss.next().unwrap(); |
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 mut ss = s.lines(); | |
| ss.next(); | |
| let teas = ss |