advent_of_code_2023/days/day06/src/part1.rs

27 lines
500 B
Rust
Raw Normal View History

2023-12-06 21:04:21 +01:00
use crate::parse::*;
pub fn part1(input: &[Race]) -> u64 {
input.iter().map(|r| r.num_ways_to_win()).product()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_part1() {
let input = vec![
Race { time: 7, record: 9 },
Race {
time: 15,
record: 40,
},
Race {
time: 30,
record: 200,
},
];
assert_eq!(part1(&input), 288);
}
}