Last active
August 29, 2015 14:10
-
-
Save joehalliwell/6c46740b623770af1361 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let target: uint = from_str(std::os::args()[1].as_slice()).unwrap(); | |
for line in std::io::stdin().lines() { | |
let l = line.unwrap(); | |
let word = l.as_slice().trim(); | |
if word.len() != target { continue; } | |
let mut chrs: Vec<char> = word.chars().collect(); | |
chrs.sort(); | |
chrs.dedup(); | |
if chrs.len() != target { continue; } | |
let diff = chrs[chrs.len() - 1].to_ascii().to_byte() - chrs[0].to_ascii().to_byte(); | |
if diff != (target - 1) as u8 { continue; } | |
print!("{}", l); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment