From c48e43a7a23f7cd4ef3bd0b8b57e1540603a0562 Mon Sep 17 00:00:00 2001 From: Shahar Talmi Date: Sat, 16 Dec 2023 12:35:26 +0200 Subject: [PATCH] refactor --- src/2023/day15.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/2023/day15.js b/src/2023/day15.js index 2dcdb3ab..2d99edc1 100644 --- a/src/2023/day15.js +++ b/src/2023/day15.js @@ -15,9 +15,7 @@ export function part1(input) { export function part2(input) { const operations = input.split(',').map(x => { const [label, focal] = x.split(/[-=]/); - return focal === '' - ? { op: '-', label } - : { op: '=', label, focal: +focal }; + return focal ? { op: '=', label, focal: +focal } : { op: '-', label }; }); const hashmap = new Array(256).fill().map(() => []); for (const operation of operations) {