fn main() { println!("Hello, world!"); let tests = [ ("AAABABB", true), ("AA", false), ("ABBBBBBBAAA", false), ("AAAABBBB", false) ]; for (input, output) in tests { let result = Solution::winner_of_game(input.to_string()); println!("{input:?} is {result} should be {output:?}"); } } struct Solution; impl Solution { pub fn winner_of_game(mut colors: String) -> bool { if colors.len() < 3 {return false;} let mut is_alice_turn = true; while ((is_alice_turn && colors.contains("AAA")) || (!is_alice_turn) && colors.contains("BBB")) { if is_alice_turn { colors = colors.replacen("AAA", "AA", 1); } else { colors = colors.replacen("BBB", "BB", 1); } is_alice_turn = !is_alice_turn } !is_alice_turn } }