Function advent_solutions::advent2017::day04::is_valid_part2
[−]
[src]
pub fn is_valid_part2(passphrase: &str) -> bool
For added security, yet another system policy has been put in place. Now, a valid passphrase must contain no two words that are anagrams of each other - that is, a passphrase is invalid if any word's letters can be rearranged to form any other word in the passphrase.
For example:
abcde fghijis a valid passphrase.assert_eq!(is_valid_part2("abcde fghij"), true);
abcde xyz ecdabis not valid - the letters from the third word can be rearranged to form the first word.assert_eq!(is_valid_part2("abcde xyz ecdab"), false);
a ab abc abd abf abjis a valid passphrase, because all letters need to be used when forming another word.assert_eq!(is_valid_part2("a ab abc abd abf abj"), true);
iiii oiii ooii oooi oooois valid.assert_eq!(is_valid_part2("iiii oiii ooii oooi oooo"), true);
oiii ioii iioi iiiois not valid - any of these words can be rearranged to form any other word.assert_eq!(is_valid_part2("oiii ioii iioi iiio"), false);