Skip to content

Commit ea79d40

Browse files
author
Reza Shiri
committed
Fix part-2 day-2
1 parent 2b320ff commit ea79d40

File tree

1 file changed

+1
-36
lines changed
  • 2022/Day 2: Rock Paper Scissors/part-1

1 file changed

+1
-36
lines changed

2022/Day 2: Rock Paper Scissors/part-1/code.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,15 @@ func scoreMove(x rune) int {
3434
return 3
3535
}
3636

37-
func myMove(oppMove rune, result rune) rune {
38-
if result == 'Z' {
39-
if oppMove == 'A' {
40-
return 'Y'
41-
}
42-
if oppMove == 'B' {
43-
return 'Z'
44-
}
45-
46-
return 'X'
47-
} else if result == 'X' {
48-
if oppMove == 'A' {
49-
return 'Z'
50-
}
51-
if oppMove == 'B' {
52-
return 'X'
53-
}
54-
55-
return 'Y'
56-
} else {
57-
if oppMove == 'A' {
58-
return 'X'
59-
}
60-
if oppMove == 'B' {
61-
return 'Y'
62-
}
63-
64-
return 'Z'
65-
}
66-
67-
return oppMove
68-
}
69-
7037
func main() {
7138
bytesRead, _ := ioutil.ReadFile("input.txt")
7239
fileContent := string(bytesRead)
7340
lines := strings.Split(fileContent, "\n")
7441

7542
var score int
7643
for _, line := range lines {
77-
first, res := rune(line[0]), rune(line[2])
78-
second := myMove(first, res)
44+
first, second := rune(line[0]), rune(line[2])
7945
score += win(first, second) + scoreMove(second)
80-
// fmt.Println(score)
8146
}
8247

8348
fmt.Println(score)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy