Skip to content

Instantly share code, notes, and snippets.

@joehalliwell
Last active August 29, 2015 14:10
Show Gist options
  • Save joehalliwell/6c46740b623770af1361 to your computer and use it in GitHub Desktop.
Save joehalliwell/6c46740b623770af1361 to your computer and use it in GitHub Desktop.
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