Skip to content

Commit 5d5572b

Browse files
committed
Day 12. Part 2
1 parent 533f352 commit 5d5572b

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

2020/12/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ describe('it should solve part 1 and part 2', () => {
3434
expect(rotations[0]({ waypoint: { x: 1, y: 3 } })).toEqual({ waypoint: { x: 1, y: 3 } });
3535
expect(rotations[1]({ waypoint: { x: 1, y: 3 } })).toEqual({ waypoint: { x: 3, y: -1 } });
3636
expect(rotations[2]({ waypoint: { x: 1, y: 3 } })).toEqual({ waypoint: { x: -1, y: -3 } });
37-
expect(rotations[3]({ waypoint: { x: 1, y: 3 } })).toEqual({ waypoint: { x: 3, y: 1 } });
37+
expect(rotations[3]({ waypoint: { x: 1, y: 3 } })).toEqual({ waypoint: { x: -3, y: 1 } });
3838
expect(rotations[1]({ waypoint: { x: 10, y: 4 } })).toEqual({ waypoint: { x: 4, y: -10 } });
3939
expect(rotations[2]({ waypoint: { x: 10, y: 4 } })).toEqual({ waypoint: { x: -10, y: -4 } });
40-
expect(rotations[3]({ waypoint: { x: 10, y: 4 } })).toEqual({ waypoint: { x: 4, y: 10 } });
40+
expect(rotations[3]({ waypoint: { x: 10, y: 4 } })).toEqual({ waypoint: { x: -4, y: 10 } });
4141
});
4242
test('it should solve example 1', () => {
4343
expect(util1(input1)).toEqual(25);

2020/12/utils.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const rotations = {
5858
},
5959
3: ({ ship, waypoint }) => {
6060
const { x, y } = waypoint;
61-
waypoint.x = y;
61+
waypoint.x = -y;
6262
waypoint.y = x;
6363
return { ship, waypoint };
6464
},
@@ -115,7 +115,6 @@ const util2 = (input) => {
115115
const { ship, waypoint } = input.reduce(
116116
({ ship, waypoint }, instruction) => {
117117
const [, letter, number] = instruction.match(/([NSEWLRF])(\d+)/) || [];
118-
console.log(letter, number, ship, waypoint);
119118
return instructions2[letter](Number(number), { ship, waypoint });
120119
},
121120
{
@@ -129,7 +128,6 @@ const util2 = (input) => {
129128
},
130129
},
131130
);
132-
console.log({ ship, waypoint });
133131
return manhattanDistance(ship);
134132
};
135133

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