Skip to content

Commit e80140d

Browse files
committed
Add problem 3360: Stone Removal Game
1 parent 969a866 commit e80140d

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,7 @@ pub mod problem_3340_check_balanced_string;
22012201
pub mod problem_3345_smallest_divisible_digit_product_i;
22022202
pub mod problem_3349_adjacent_increasing_subarrays_detection_i;
22032203
pub mod problem_3350_adjacent_increasing_subarrays_detection_ii;
2204+
pub mod problem_3360_stone_removal_game;
22042205

22052206
#[cfg(test)]
22062207
mod test_utilities;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
pub struct Solution;
2+
3+
// ------------------------------------------------------ snip ------------------------------------------------------ //
4+
5+
impl Solution {
6+
pub fn can_alice_win(n: i32) -> bool {
7+
matches! (n, 10..19 | 27..34 | 40..45 | 49..)
8+
}
9+
}
10+
11+
// ------------------------------------------------------ snip ------------------------------------------------------ //
12+
13+
impl super::Solution for Solution {
14+
fn can_alice_win(n: i32) -> bool {
15+
Self::can_alice_win(n)
16+
}
17+
}
18+
19+
#[cfg(test)]
20+
mod tests {
21+
#[test]
22+
fn test_solution() {
23+
super::super::tests::run::<super::Solution>();
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub mod brute_force;
2+
3+
pub trait Solution {
4+
fn can_alice_win(n: i32) -> bool;
5+
}
6+
7+
#[cfg(test)]
8+
mod tests {
9+
use super::Solution;
10+
11+
pub fn run<S: Solution>() {
12+
for (n, expected) in [(1, false), (12, true)] {
13+
assert_eq!(S::can_alice_win(n), expected);
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)