File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, Christopher Friedt
3
+ *
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ #include < gtest/gtest.h>
8
+
9
+ #include " divisor-game.cpp"
10
+
11
+ using namespace std ;
12
+
13
+ TEST (DivisorGame, 2 ) { EXPECT_EQ (true , Solution ().divisorGame (2 )); }
14
+
15
+ TEST (DivisorGame, 3 ) { EXPECT_EQ (false , Solution ().divisorGame (3 )); }
16
+
17
+ TEST (DivisorGame, 4 ) { EXPECT_EQ (true , Solution ().divisorGame (4 )); }
18
+
19
+ TEST (DivisorGame, 5 ) { EXPECT_EQ (false , Solution ().divisorGame (5 )); }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, Christopher Friedt
3
+ *
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+
7
+ // clang-format off
8
+ // name: divisor-game
9
+ // url: https://leetcode.com/problems/divisor-game
10
+ // difficulty: 1
11
+ // clang-format on
12
+
13
+ #include < climits>
14
+
15
+ using namespace std ;
16
+
17
+ class Solution {
18
+ public:
19
+ bool divisorGame (int N) {
20
+ enum player {
21
+ ALICE,
22
+ BOB,
23
+ };
24
+
25
+ uint8_t loser;
26
+ for (loser = ALICE; 1 != N; --N, loser ^= 1 )
27
+ ;
28
+ return loser == BOB;
29
+ }
30
+ };
You can’t perform that action at this time.
0 commit comments