Skip to content

Commit dc33543

Browse files
committed
AoC 2024, Day 1: Parse input
1 parent 5c9e057 commit dc33543

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

go/2024/day01.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bufio"
55
"fmt"
66
"os"
7+
"strconv"
8+
"strings"
79
)
810

911
func main() {
@@ -16,11 +18,21 @@ func main() {
1618
defer fi.Close()
1719

1820
scanner := bufio.NewScanner(fi)
21+
var left []int
22+
var right []int
1923

2024
for scanner.Scan() {
21-
fmt.Println(scanner.Text())
25+
line := scanner.Text()
26+
pair := strings.Split(line, " ")
27+
p1, _ := strconv.Atoi(pair[0])
28+
p2, _ := strconv.Atoi(pair[1])
29+
left = append(left, p1)
30+
right = append(left, p2)
2231
}
2332

33+
fmt.Println(left)
34+
fmt.Println(right)
35+
2436
if err := scanner.Err(); err != nil {
2537
panic(err)
2638
}

0 commit comments

Comments
 (0)