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 cached::proc_macro::cached; | |
| use itertools::Itertools; | |
| const INPUT: &str = include_str!("inputs/day02.txt"); | |
| fn parse(input: &str) -> impl Iterator<Item = char> { | |
| input.trim().chars() | |
| } |
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 cached::proc_macro::cached; | |
| use itertools::Itertools; | |
| const INPUT: &str = include_str!("inputs/day02.txt"); | |
| fn parse(input: &str) -> impl Iterator<Item = char> { | |
| input.trim().chars() | |
| } |
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/01.txt"); | |
| fn parse(input: &str) -> impl Iterator<Item = &str> { | |
| input.trim().lines() | |
| } | |
| fn p1(input: &str) -> usize { | |
| parse(input).map(|l| l.len() / 2).sum() |
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> { | |
| // TODO did you trim today? | |
| input.trim().lines() | |
| } | |
| fn p1(input: &str) -> usize { |
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 imports = m | |
| .split_whitespace() | |
| .map(|v| v.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::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 vv = m | |
| .split_whitespace() | |
| .map(|v| v.parse::<f64>().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 s = s.trim().parse::<usize>().unwrap(); | |
| println!("{s}:"); | |
| (2..=(s / 2 + 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 lines = s.lines(); | |
| while let Some(line) = lines.next() { | |
| let n = match line.parse::<usize>() { |
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 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) { | |
| let v = m | |
| .split_whitespace() | |
| .map(|v| v.parse::<isize>().unwrap()) |
NewerOlder