Skip to content

Commit 6583225

Browse files
committed
Change to the template and script
1 parent a43bc02 commit 6583225

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

download.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ cd "$YEAR/$DAY" || exit
99

1010
if [ ! -f main1.go ]; then cp ../../go.template main1.go; fi
1111
if [ ! -f main2.go ]; then cp ../../go.template main2.go; fi
12+
if [ ! -f common.go ]; then echo "package main" > common.go; fi
1213

1314
if [ ! -f Makefile ]; then cat >Makefile <<EOF
1415
input:
1516
http "https://adventofcode.com/$YEAR/day/$DAY/input" "Cookie:session=\${AOC_SESSION};" >input
1617
1718
main1:
18-
go build -o main1 main1.go
19+
go build -o main1 main1.go common.go
1920
2021
main2:
21-
go build -o main2 main2.go
22+
go build -o main2 main2.go common.go
2223
2324
.PHONY: run1 run2 clean
2425

go.template

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import (
77
)
88

99
func main() {
10-
scanner := bufio.NewScanner(os.Stdin)
10+
x := parseInput
11+
12+
fmt.Println(x)
13+
}
1114

15+
func parseInput() []int {
16+
var list []int
17+
scanner := bufio.NewScanner(os.Stdin)
1218
for scanner.Scan() {
1319
line := scanner.Text()
1420

21+
list = append(list, line)
1522
}
16-
17-
fmt.Println()
18-
}
23+
return list
24+
}

0 commit comments

Comments
 (0)