Skip to content

Commit

Permalink
Update alphametics
Browse files Browse the repository at this point in the history
  • Loading branch information
vhgcuong committed Oct 20, 2023
1 parent 7803fe1 commit 0ac365a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/alphametics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
use itertools::Itertools;

pub fn solve(input: &str) -> Option<HashMap<char, u8>> {
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();
Expand Down
10 changes: 9 additions & 1 deletion src/isbn_verifier.rs
Original file line number Diff line number Diff line change
@@ -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?");
}
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use exercism::isbn_verifier;
fn main() {

isbn_verifier::is_valid_isbn("3-598-21507-X");
}

0 comments on commit 0ac365a

Please sign in to comment.