From 0f3f6f287558abbab242f8e4f319148be2775e37 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Fri, 3 Dec 2021 19:08:25 -0500 Subject: [PATCH] only check bitlen once --- 03/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/03/main.go b/03/main.go index 4e55e21..34d84eb 100644 --- a/03/main.go +++ b/03/main.go @@ -62,12 +62,14 @@ func partTwo() { inputs := []int64{} var oxgen, co2scrub int64 - var bitlen int64 + var bitlen int for scanner.Scan() { line := scanner.Text() + if bitlen == 0 { + bitlen = len(line) + } n, _ := strconv.ParseInt(line, 2, 64) inputs = append(inputs, n) - bitlen = int64(len(line)) } // on initial loop, oxgen>>i == n>>i etc always come out to 0 == 0