diff --git a/src/problem/mod.rs b/src/problem/mod.rs index dc334c2..4ca4c2e 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -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; diff --git a/src/problem/p3222_find_the_winning_player_in_coin_game.rs b/src/problem/p3222_find_the_winning_player_in_coin_game.rs new file mode 100644 index 0000000..fd591b9 --- /dev/null +++ b/src/problem/p3222_find_the_winning_player_in_coin_game.rs @@ -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)); + } +}