Function aoc::year2019::day16::binomial_mod_2
source ยท fn binomial_mod_2(n: usize, k: usize) -> usize
Expand description
Computes C(n, k) % 2
This collapses to a special case of a product of only 4 possible values:
C(0, 0) = 1
C(1, 0) = 1
C(1, 1) = 1
C(0, 1) = 0
So the final value will always be one or zero. The fourth zero case happens when k
has a
bit not present in n
so we can compute the final value using bitwise logic.