advent2022

Advent of Code 2022 Solutions
git clone git://bsandro.tech/advent2022
Log | Files | Refs | README | LICENSE

commit bffe9d224e20eb20dc175e0396fb7090eb1c6bba
parent 7d66a1776876b3a7c4b26d4cec346eaa7dbdd1c7
Author: bsandro <email@bsandro.tech>
Date:   Sat,  3 Dec 2022 10:49:02 +0200

Day 01 bugfix + sample.txt

Diffstat:
Mday01/main.go | 8+++++---
Aday01/sample.txt | 14++++++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/day01/main.go b/day01/main.go @@ -11,7 +11,7 @@ import ( func main() { if len(os.Args) > 1 { - day0102(os.Args[1]) + day01(os.Args[1]) } else if len(os.Args) == 1 { fmt.Printf("usage: %s inputfile.txt\n", os.Args[0]) } else { @@ -19,8 +19,8 @@ func main() { } } -func day0102(input_file string) { - fmt.Printf("day 01 input filename: %s\n", input_file) +func day01(input_file string) { + fmt.Printf("Day 01 input filename: %s\n", input_file) input, err := os.Open(input_file) if err != nil { log.Fatal(err) @@ -41,6 +41,8 @@ func day0102(input_file string) { cur_load = 0 } } + // processing last block separately since there is no \r\n there at the end + loads = append(loads, cur_load) if err = scanner.Err(); err != nil { log.Fatal(err) } diff --git a/day01/sample.txt b/day01/sample.txt @@ -0,0 +1,14 @@ +1000 +2000 +3000 + +4000 + +5000 +6000 + +7000 +8000 +9000 + +10000