From b2cfa5ca5712573b4b2c40880e0dc7c60effdc1e Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Sun, 4 Dec 2022 11:58:25 -0800 Subject: [PATCH] tidy up --- 2022-aoc/src/d4.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/2022-aoc/src/d4.rs b/2022-aoc/src/d4.rs index 3233cc5..28bd491 100644 --- a/2022-aoc/src/d4.rs +++ b/2022-aoc/src/d4.rs @@ -1,6 +1,7 @@ use aoc_runner_derive::{aoc as aoc_run, aoc_generator}; -type Assignments = ((u32, u32), (u32, u32)); +type TRange = (u32, u32); +type Assignments = (TRange, TRange); #[aoc_generator(day4)] fn parse_input(input: &str) -> Vec { @@ -36,15 +37,15 @@ fn part2(scheds: &[Assignments]) -> u32 { out } -fn get_range(r: &str) -> (u32, u32) { +fn get_range(r: &str) -> TRange { let (lo, hi) = r.split_once('-').unwrap(); (lo.parse().unwrap(), hi.parse().unwrap()) } -fn contains(a: &(u32, u32), b: &(u32, u32)) -> bool { +fn contains(a: &TRange, b: &TRange) -> bool { a.0 <= b.0 && b.1 <= a.1 } -fn overlaps(a: &(u32, u32), b: &(u32, u32)) -> bool { +fn overlaps(a: &TRange, b: &TRange) -> bool { a.0 <= b.0 && b.0 <= a.1 }