File tree Expand file tree Collapse file tree 1 file changed +28
-22
lines changed
Expand file tree Collapse file tree 1 file changed +28
-22
lines changed Original file line number Diff line number Diff line change @@ -20,30 +20,30 @@ pub fn part1(s: &str) -> u32 {
2020 unsafe { part1_inner ( s) }
2121}
2222
23- const SHIFT_LUT : [ u64 ; ( SIZE * SIZE * 2 ) as usize ] = {
24- let mut lut = [ 0 ; ( SIZE * SIZE * 2 ) as usize ] ;
23+ // const SHIFT_LUT: [u64; (SIZE * SIZE * 2) as usize] = {
24+ // let mut lut = [0; (SIZE * SIZE * 2) as usize];
2525
26- let mut x = 0 ;
27- while x < SIZE {
28- let mut diff_x = -SIZE + 1 ;
26+ // let mut x = 0;
27+ // while x < SIZE {
28+ // let mut diff_x = -SIZE + 1;
2929
30- let field = 1 << x;
30+ // let field = 1 << x;
3131
32- while diff_x < SIZE {
33- lut[ ( x * SIZE * 2 + diff_x + SIZE - 1 ) as usize ] = if diff_x. is_positive ( ) {
34- field << diff_x
35- } else {
36- field >> -diff_x
37- } ;
32+ // while diff_x < SIZE {
33+ // lut[(x * SIZE * 2 + diff_x + SIZE - 1) as usize] = if diff_x.is_positive() {
34+ // field << diff_x
35+ // } else {
36+ // field >> -diff_x
37+ // };
3838
39- diff_x += 1 ;
40- }
39+ // diff_x += 1;
40+ // }
4141
42- x += 1 ;
43- }
42+ // x += 1;
43+ // }
4444
45- lut
46- } ;
45+ // lut
46+ // };
4747
4848unsafe fn part1_inner ( s : & str ) -> u32 {
4949 #[ cfg( not( test) ) ]
@@ -79,15 +79,21 @@ unsafe fn part1_inner(s: &str) -> u32 {
7979 if * mast_y >= diff_y {
8080 let node_y = mast_y - diff_y;
8181
82- * antinodes. get_unchecked_mut ( node_y as usize ) |=
83- SHIFT_LUT [ ( mast_x * SIZE * 2 + diff_x + SIZE - 1 ) as usize ] ;
82+ * antinodes. get_unchecked_mut ( node_y as usize ) |= if diff_x. is_positive ( ) {
83+ 1 << mast_x << diff_x
84+ } else {
85+ 1 << mast_x >> -diff_x
86+ } ;
8487 }
8588
8689 if new_y + diff_y < SIZE {
8790 let node_y = new_y + diff_y;
8891
89- * antinodes. get_unchecked_mut ( node_y as usize ) |=
90- SHIFT_LUT [ ( new_x * SIZE * 2 - diff_x + SIZE - 1 ) as usize ] ;
92+ * antinodes. get_unchecked_mut ( node_y as usize ) |= if diff_x. is_positive ( ) {
93+ 1 << new_x << diff_x
94+ } else {
95+ 1 << new_x >> -diff_x
96+ } ;
9197 }
9298 }
9399
You can’t perform that action at this time.
0 commit comments