File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565//!
6666//! Using the bits as labelled above, the next cell is `(e|s) & (q^r) & !p`, masked back
6767//! to the 50 bits per integer.
68-
6968const MASK : u64 = ( 1 << 50 ) - 1 ;
7069const LEFT_CORNER : u64 = 1 << 49 ;
7170const RIGHT_CORNER : u64 = 1 << 0 ;
Original file line number Diff line number Diff line change 88//! part one requires more than 50 steps but should easily be reachable without exceeding bounds,
99//! we can bound the maze to 2 + 50 = 52 in each dimension and use a fixed-size array. Rather
1010//! than filling the array up front, we can lazily populate it as the horizon expands.
11-
1211use crate :: util:: parse:: * ;
1312use std:: collections:: VecDeque ;
1413
Original file line number Diff line number Diff line change 1414//!
1515//! [`day 5`]: crate::year2020::day05
1616//! [`count_ones`]: u32::count_ones
17-
1817pub fn parse ( input : & str ) -> Vec < u32 > {
1918 input. lines ( ) . map ( |line| line. bytes ( ) . fold ( 0 , |acc, b| acc | ( 1 << ( b - b'a' ) ) ) ) . collect ( )
2019}
Original file line number Diff line number Diff line change 22//!
33//! Part one is solved with an efficient `O(n)` algorithm. Part two is also solved with an efficient `O(n)`
44//! algorithm, using a bit manipulation trick to make the complexity independent of the number of digits.
5-
65const ONES : u64 = 0x0041041041041041 ;
76const MASK : u64 = 0x0fffffffffffffc0 ;
87
You can’t perform that action at this time.
0 commit comments