35 lines
962 B
Rust
35 lines
962 B
Rust
// To ensure security, a valid passphrase must contain no duplicate words.
|
|
//
|
|
// For example:
|
|
//
|
|
// aa bb cc dd ee is valid.
|
|
// aa bb cc dd aa is not valid - the word aa appears more than once.
|
|
// aa bb cc dd aaa is valid - aa and aaa count as different words.
|
|
// The system's full passphrase list is available as your puzzle input. How many passphrases are valid?
|
|
//
|
|
|
|
use std::collections::HashMap;
|
|
use core::read_data;
|
|
|
|
fn is_valid(input: &str) -> bool {
|
|
let parts = input.split(' ');
|
|
let mut working = HashMap::new();
|
|
|
|
for part in parts {
|
|
working.entry(part);
|
|
}
|
|
true
|
|
}
|
|
|
|
fn main() {
|
|
// let binding = read_data("2017_04_data.txt");
|
|
let params = vec![
|
|
("aa bb cc dd ee", true),
|
|
("aa bb cc dd aa", false),
|
|
("aa bb cc dd aaa", true)
|
|
];
|
|
for (input, expected) in params {
|
|
let actual = is_valid(input);
|
|
println!("||{input}|| was expected to be {expected} but was {actual}");
|
|
}
|
|
} |