Skip to content

Commit 7c28bfa

Browse files
author
openset
committed
Add: Divisor Game
1 parent 1dc25ad commit 7c28bfa

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

problems/divisor-game/divisor_game.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package divisor_game
2+
3+
func divisorGame(N int) bool {
4+
return N&1 == 0
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package divisor_game
2+
3+
import "testing"
4+
5+
type caseType struct {
6+
input int
7+
expected bool
8+
}
9+
10+
func TestDivisorGame(t *testing.T) {
11+
tests := [...]caseType{
12+
{
13+
input: 2,
14+
expected: true,
15+
},
16+
{
17+
input: 3,
18+
expected: false,
19+
},
20+
}
21+
for _, tc := range tests {
22+
output := divisorGame(tc.input)
23+
if output != tc.expected {
24+
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)