20241105 finished.

This commit is contained in:
jackfiled 2024-11-05 13:31:02 +08:00
parent 99d9f6e1a7
commit 78b0efc886
2 changed files with 33 additions and 0 deletions

View File

@ -296,3 +296,5 @@ mod p3226_number_of_bit_changes_to_make_two_integers_equal;
mod p638_shopping_offers; mod p638_shopping_offers;
mod p633_sum_of_square_numbers; mod p633_sum_of_square_numbers;
mod p3222_find_the_winning_player_in_coin_game;

View 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));
}
}