Skip to content

Commit 1db00c3

Browse files
committed
Clean up
1 parent b8c20ac commit 1db00c3

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

bin/day_2

-1.94 MB
Binary file not shown.

day_1/go.mod

Lines changed: 0 additions & 3 deletions
This file was deleted.

day_2/go.mod

Lines changed: 0 additions & 3 deletions
This file was deleted.

day_2/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,13 @@ func calculateScore(reader io.Reader) int {
4747

4848
for scanner.Scan() {
4949
line := strings.TrimSuffix(scanner.Text(), "\n")
50-
lineParts := strings.Split(line, " ")
5150

52-
opponentMove := MapOpponentMove(lineParts[0])
51+
opponentMove := MapOpponentMove(string(line[0]))
5352

54-
r := Round{
53+
score += Round{
5554
OpponentMove: opponentMove,
56-
PlayerMove: SelectPlayerMove(opponentMove, MapPlayerStrategy(lineParts[1])),
57-
}
58-
59-
score += r.Score()
55+
PlayerMove: SelectPlayerMove(opponentMove, MapPlayerStrategy(string(line[2]))),
56+
}.Score()
6057
}
6158

6259
if err := scanner.Err(); err != nil {

day_2/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func Test_calculateScore(t *testing.T) {
2020
args: args{
2121
reader: strings.NewReader(strings.Join([]string{"A Y", "B X", "C Z"}, "\n")),
2222
},
23-
want: 15,
23+
want: 12,
2424
},
2525
}
2626
for _, tt := range tests {

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/dwethmar/adventofcode2022
2+
3+
go 1.19

0 commit comments

Comments
 (0)