Use tuple_map to map tuples
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
use crate::read;
|
||||
use tuple_map::*;
|
||||
|
||||
fn get_ranges(elf: &str) -> std::ops::RangeInclusive<i32> {
|
||||
let r = elf
|
||||
.split_once('-')
|
||||
.map(|e| (e.0.parse().unwrap(), e.1.parse().unwrap()))
|
||||
.unwrap();
|
||||
let r = elf.split_once('-').unwrap().map(|e| e.parse().unwrap());
|
||||
r.0..=r.1
|
||||
}
|
||||
|
||||
@ -13,10 +11,7 @@ pub fn run() {
|
||||
|
||||
let lines = input
|
||||
.lines()
|
||||
.map(|l| {
|
||||
let pairs = l.split_once(',').unwrap();
|
||||
(get_ranges(pairs.0), get_ranges(pairs.1))
|
||||
})
|
||||
.map(|l| l.split_once(',').unwrap().map(get_ranges))
|
||||
.collect::<Vec<_>>();
|
||||
#[cfg(feature = "part1")]
|
||||
{
|
||||
|
Reference in New Issue
Block a user