This commit is contained in:
2022-12-03 12:14:30 +01:00
parent e84c13c689
commit aee2b49c64
3 changed files with 111 additions and 0 deletions

24
day03/ex1/main.go Normal file
View File

@@ -0,0 +1,24 @@
package main
import (
"bufio"
"fmt"
"os"
"aoc2022/day03/common"
)
func main() {
rucksacks := common.Parse(*bufio.NewScanner(os.Stdin))
sum := 0
for _, rucksack := range rucksacks {
for _, item := range rucksack.GetCompartment(1).GetItems() {
if rucksack.GetCompartment(2).ContainsItem(item) {
sum += item
break
}
}
}
fmt.Println(sum)
}