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/day05.txt"); | |
| fn parse(input: &str) -> Vec<isize> { | |
| input.lines().map(|l| l.parse::<isize>().unwrap()).collect() | |
| } | |
| fn p1(input: &str) -> usize { | |
| let mut input = 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; | |
| use rustc_hash::FxHashSet; | |
| const INPUT: &str = include_str!("inputs/day04.txt"); | |
| fn parse(input: &str) -> impl Iterator<Item = Vec<&str>> { | |
| input.lines().map(|l| l.split_whitespace().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::io::{Read, stdin}; | |
| fn main() { | |
| let mut s = String::new(); | |
| stdin().read_to_string(&mut s).unwrap(); | |
| let mut ss = s.lines(); | |
| let t = ss.next().unwrap().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(); | |
| let mut ss = s.lines(); | |
| let n = ss.next().unwrap().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(); | |
| let mut lines = s.lines(); | |
| let mut pp = lines | |
| .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 shares = 0.0f64; | |
| let mut avg = 0.0f64; | |
| for m in 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::io::{Read, stdin}; | |
| fn main() { | |
| let mut s = String::new(); | |
| stdin().read_to_string(&mut s).unwrap(); | |
| let mut ss = s.split_whitespace().map(|v| v.parse::<isize>().unwrap()); | |
| let n = ss.next().unwrap(); | |
| let r = ss.next().unwrap(); | |
| let k = 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 lines = s.lines(); | |
| while let Some(l) = lines.next() { | |
| if l == "0 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(); | |
| let n = s.trim().parse::<i32>().unwrap(); | |
| // <= 3 == 1 | |
| println!("{}", (n - 2).max(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::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() | |
| } |
NewerOlder