20240204 Finished
This commit is contained in:
parent
495f019092
commit
44ea4b727a
|
@ -36,4 +36,5 @@ mod p2808_minimum_seconds_to_equalize_a_circular_array;
|
||||||
mod p2670_find_the_distinct_difference_array;
|
mod p2670_find_the_distinct_difference_array;
|
||||||
mod lcp24_nums_game;
|
mod lcp24_nums_game;
|
||||||
mod p1686_stone_game_vi;
|
mod p1686_stone_game_vi;
|
||||||
mod p1690_stone_game_vii;
|
mod p1690_stone_game_vii;
|
||||||
|
mod p292_nim_game;
|
26
src/problem/p292_nim_game.rs
Normal file
26
src/problem/p292_nim_game.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* [292] Nim Game
|
||||||
|
*/
|
||||||
|
pub struct Solution {}
|
||||||
|
|
||||||
|
|
||||||
|
// submission codes start here
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn can_win_nim(n: i32) -> bool {
|
||||||
|
n % 4 != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// submission codes end
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_292() {
|
||||||
|
assert!(Solution::can_win_nim(5));
|
||||||
|
assert!(!Solution::can_win_nim(4));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user