File tree Expand file tree Collapse file tree 1 file changed +1
-36
lines changed
2022/Day 2: Rock Paper Scissors/part-1 Expand file tree Collapse file tree 1 file changed +1
-36
lines changed Original file line number Diff line number Diff line change @@ -34,50 +34,15 @@ func scoreMove(x rune) int {
34
34
return 3
35
35
}
36
36
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
-
70
37
func main () {
71
38
bytesRead , _ := ioutil .ReadFile ("input.txt" )
72
39
fileContent := string (bytesRead )
73
40
lines := strings .Split (fileContent , "\n " )
74
41
75
42
var score int
76
43
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 ])
79
45
score += win (first , second ) + scoreMove (second )
80
- // fmt.Println(score)
81
46
}
82
47
83
48
fmt .Println (score )
You can’t perform that action at this time.
0 commit comments