20241105 finished.
This commit is contained in:
parent
99d9f6e1a7
commit
78b0efc886
|
@ -296,3 +296,5 @@ mod p3226_number_of_bit_changes_to_make_two_integers_equal;
|
|||
mod p638_shopping_offers;
|
||||
|
||||
mod p633_sum_of_square_numbers;
|
||||
|
||||
mod p3222_find_the_winning_player_in_coin_game;
|
||||
|
|
31
src/problem/p3222_find_the_winning_player_in_coin_game.rs
Normal file
31
src/problem/p3222_find_the_winning_player_in_coin_game.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* [3222] Find the Winning Player in Coin Game
|
||||
*/
|
||||
pub struct Solution {}
|
||||
|
||||
// submission codes start here
|
||||
|
||||
impl Solution {
|
||||
pub fn losing_player(x: i32, y: i32) -> String {
|
||||
let count = x.min(y / 4);
|
||||
|
||||
if count % 2 == 1 {
|
||||
"Alice".to_owned()
|
||||
} else {
|
||||
"Bob".to_owned()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// submission codes end
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_3222() {
|
||||
assert_eq!("Alice".to_owned(), Solution::losing_player(2, 7));
|
||||
assert_eq!("Bob".to_owned(), Solution::losing_player(4, 11));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user