We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5c9e057 commit dc33543Copy full SHA for dc33543
go/2024/day01.go
@@ -4,6 +4,8 @@ import (
4
"bufio"
5
"fmt"
6
"os"
7
+ "strconv"
8
+ "strings"
9
)
10
11
func main() {
@@ -16,11 +18,21 @@ func main() {
16
18
defer fi.Close()
17
19
20
scanner := bufio.NewScanner(fi)
21
+ var left []int
22
+ var right []int
23
24
for scanner.Scan() {
- 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)
31
}
32
33
+ fmt.Println(left)
34
+ fmt.Println(right)
35
+
36
if err := scanner.Err(); err != nil {
37
panic(err)
38
0 commit comments