Expand description
§Custom Customs
This is a disguised binary question like the previous day 5
.
We can store each passenger’s answers as an implicit set in a u32
since the cardinality
is only 26. For each yes answer we set a bit, shifting left based on the letter. For example
acf
would be represented as 100101
.
For part one to find groups where any person answered yes, we reduce the group using
bitwise OR then count the number of ones
for each group using the blazing fast count_ones
intrinsic.
Part two is very similar, except that we use a bitwise AND instead.