Skip to content

Commit f0fc71e

Browse files
2024: Optimize day 22
1 parent 0002c16 commit f0fc71e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

2024/day22/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ fn main() {
1717
let mut old_price = n % 10;
1818
for i in 0..2000 {
1919
n ^= n << 6;
20-
n %= 16777216;
20+
n &= 16777215; // same as `% 16777216` but faster
2121

2222
n ^= n >> 5;
23-
n %= 16777216;
23+
// n &= 16777215; // unnecessary
2424

2525
n ^= n << 11;
26-
n %= 16777216;
26+
n &= 16777215;
2727

2828
let price = n % 10;
2929
let diff = price - old_price;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy