Skip to content

Instantly share code, notes, and snippets.

@CryZe
Created February 14, 2016 19:09
Show Gist options
  • Select an option

  • Save CryZe/a5adb8d817dbb0f47c1f to your computer and use it in GitHub Desktop.

Select an option

Save CryZe/a5adb8d817dbb0f47c1f to your computer and use it in GitHub Desktop.
xkcd-936
mod words;
extern crate rand;
use rand::{thread_rng, Rng};
use std::collections::HashSet;
use words::WORDS;
fn main() {
let mut rng = thread_rng();
let mut random_words = HashSet::new();
while random_words.len() < 4 {
let i = rng.gen_range(0, WORDS.len());
random_words.insert(WORDS[i]);
}
for word in random_words {
print!("{}", word);
}
println!("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment