use crate::util::parse::*;
pub fn parse(input: &str) -> Vec<usize> {
input
.lines()
.map(|line| {
let mut found = [false; 100];
let (win, have) = line.split_once('|').unwrap();
win.iter_unsigned::<usize>().skip(1).for_each(|i| found[i] = true);
have.iter_unsigned::<usize>().filter(|&i| found[i]).count()
})
.collect()
}
pub fn part1(input: &[usize]) -> u32 {
input.iter().map(|&n| (1 << n) >> 1).sum()
}
pub fn part2(input: &[usize]) -> u32 {
let mut copies = vec![1; input.len()];
for (i, &n) in input.iter().enumerate() {
(1..=n).for_each(|j| copies[i + j] += copies[i]);
}
copies.iter().sum()
}