From 4792a10a7c03c19241172b83d330ccbde8f7bb29 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 13 Dec 2020 12:26:59 +0100 Subject: [PATCH] Optimize 2020/12 This is about 10% faster for part 2. mod is bad. --- 2020/src/bin/day12.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2020/src/bin/day12.rs b/2020/src/bin/day12.rs index ca0a3e5..c43f1dd 100644 --- a/2020/src/bin/day12.rs +++ b/2020/src/bin/day12.rs @@ -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