44 lines
872 B
Rust
44 lines
872 B
Rust
use aoc_runner_derive::{aoc, aoc_generator};
|
|
|
|
#[aoc_generator(day17)]
|
|
fn parse(input: &str) -> Vec<u32> {
|
|
input.lines().map(|line| line.parse().unwrap()).collect()
|
|
}
|
|
|
|
#[aoc(day17, part1)]
|
|
fn part1(input: &[u32]) -> usize {
|
|
bar(input, 150)
|
|
}
|
|
|
|
fn bar(containers: &[u32], target: u32) -> usize {
|
|
baz(containers, target, 0)
|
|
}
|
|
|
|
fn baz(containers: &[u32], target: u32, filled: u32) -> usize {
|
|
if filled > target {
|
|
return 0;
|
|
} else if filled == target {
|
|
return 1;
|
|
} else if containers.len() == 0 {
|
|
return 0;
|
|
}
|
|
|
|
baz(&containers[1..], target, filled + containers[0])
|
|
+ baz(&containers[1..], target, filled)
|
|
}
|
|
|
|
#[aoc(day17, part2)]
|
|
fn part2(_input: &[u32]) -> usize {
|
|
0
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use crate::day17::bar;
|
|
|
|
#[test]
|
|
fn part1() {
|
|
assert_eq!(bar(&[20, 15, 10, 5, 5], 25), 4)
|
|
}
|
|
}
|