diff --git a/src/alphametics.rs b/src/alphametics.rs index 48ce1d2..e6c93de 100644 --- a/src/alphametics.rs +++ b/src/alphametics.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; pub fn solve(input: &str) -> Option> { - let mut iter = input.clone().split("=="); + let mut iter = input.split("=="); let sum: Vec<&str> = iter.next().unwrap().split("+").map(|x| x.trim()).collect(); let answer: &str = iter.next().unwrap().trim(); diff --git a/src/isbn_verifier.rs b/src/isbn_verifier.rs index c500b0b..519a50a 100644 --- a/src/isbn_verifier.rs +++ b/src/isbn_verifier.rs @@ -1,4 +1,12 @@ /// Determines whether the supplied string is a valid ISBN number pub fn is_valid_isbn(isbn: &str) -> bool { - todo!("Is {isbn:?} a valid ISBN number?"); + if isbn.is_empty() { + return false; + } + + let isbn_digit: Vec<_> = isbn.to_string().chars().filter(|c| c.is_ascii_digit()).collect(); + println!("{:?}", isbn_digit); + + true + // todo!("Is {isbn:?} a valid ISBN number?"); } diff --git a/src/main.rs b/src/main.rs index 2a778e4..1c5c486 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use exercism::isbn_verifier; fn main() { - + isbn_verifier::is_valid_isbn("3-598-21507-X"); }