Optimize 2020/12

This is about 10% faster for part 2. mod is bad.
This commit is contained in:
kageru 2020-12-13 12:26:59 +01:00
parent e2464b1d3e
commit 4792a10a7c
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -32,7 +32,7 @@ fn part1(parsed: &Parsed) -> i64 {
}
fn rotate_waypoint(mut wp: Position2D, deg: i64) -> Position2D {
for _ in 0..((deg / 90 + 4) % 4) {
for _ in 0..((deg / 90 + 4) & 3) {
wp = Position2D { x: wp.y, y: -wp.x };
}
wp