MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / part_two

Function part_two

2020/src/bin/10.rs:43–54  ·  view source on GitHub ↗
(v: &[usize])

Source from the content-addressed store, hash-verified

41}
42
43fn part_two(v: &[usize]) -> usize {
44 let mut dp = HashMap::new();
45 dp.insert(0, 1);
46 for &i in v {
47 let ans =
48 dp.get(&(i-1)).unwrap_or(&0) +
49 dp.get(&(i-2)).unwrap_or(&0) +
50 dp.get(&(i-3)).unwrap_or(&0);
51 dp.insert(i, ans);
52 }
53 dp[v.last().unwrap()]
54}
55
56aoc2020::main! {
57 let v = INPUT.iter()

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected