From e7635b5e4cef8cf189455f03ca0320779980f2c4 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 15 Dec 2023 19:51:15 +0000 Subject: [PATCH] remove add, remove functions. --- day-15/two.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/day-15/two.go b/day-15/two.go index 089a447..fed86d9 100644 --- a/day-15/two.go +++ b/day-15/two.go @@ -8,16 +8,6 @@ import ( var boxes = map[int]*orderedmap.OrderedMap[string, int]{} -// add places a lense into an ordered box -func add(id int, label string, focalLength int) { - boxes[id].Set(label, focalLength) -} - -// remove takes a lense out of an ordered box -func remove(id int, label string) { - boxes[id].Delete(strings.TrimRight(label, "-")) -} - // two returns the sum of all lense configurations func two(lines []string) int { hash := newHasher() @@ -38,9 +28,9 @@ func two(lines []string) int { } if strings.Contains(lense, "=") { - add(boxId, label, focalLength) + boxes[boxId].Set(label, focalLength) } else { - remove(boxId, label) + boxes[boxId].Delete(strings.TrimRight(label, "-")) } }