Skip to content

Instantly share code, notes, and snippets.



Forked from rust-play/
Last active Jun 3, 2020
What would you like to do?
pub fn xo (value: &str) -> bool {
let value = value.to_lowercase();
let count_x = value.matches("x").count();
let count_o = value.matches("o").count();
count_x == count_o
mod tests {
use super::*;
fn test_1() {
assert_eq!(xo("ooxx"), true);
fn test_2() {
assert_eq!(xo("xooxx"), false);
fn test_3() {
assert_eq!(xo("ooxXm"), true);
fn test_4() {
assert_eq!(xo("zzoo"), false);
fn test_5() {
assert_eq!(xo("zpzpzpp"), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment