Created
February 14, 2016 19:09
-
-
Save CryZe/a5adb8d817dbb0f47c1f to your computer and use it in GitHub Desktop.
xkcd-936
This file contains hidden or 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
| 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