diff --git a/src/random/hard_words.rs b/src/random/hard_words.rs new file mode 100644 index 0000000..8040843 --- /dev/null +++ b/src/random/hard_words.rs @@ -0,0 +1,32 @@ +use rand::seq::IteratorRandom; +use rand::thread_rng; + +pub fn random_hard_english_words(max: u32) -> String { + let mut random_words = String::new(); + for _i in 0..max { + if let Some(word) = random_hard_words() { + random_words.push_str(word.as_str()); + } + } + + random_words.trim_end().into() +} + +fn random_hard_words() -> Option { + let mut rng = thread_rng(); + let subs = [ + "antidisestablishmentarianism", + "supercalifragilisticexpialidocious", + "pneumonoultramicroscopicsilicovolcanoconiosis", + "floccinaucinihilipilification", + "hippopotomonstrosesquipedaliophobia", + "worcestershire", + "entrepreneur", + "conscientious", + "unquestionably", + "labyrinth", + ]; + let sample = subs.iter().choose(&mut rng); + + sample.map(|s| s.to_owned().to_owned()) +} diff --git a/src/random/mod.rs b/src/random/mod.rs index 37dd5f4..5fc2663 100644 --- a/src/random/mod.rs +++ b/src/random/mod.rs @@ -2,7 +2,9 @@ use self::{ letters::random_letters_inner, rustfun::random_function, sentences::random_english_sentences, symbols::random_symbols, words::random_english_words, }; +use crate::random::hard_words::random_hard_english_words; +mod hard_words; mod letters; mod rustfun; mod sentences; @@ -18,7 +20,7 @@ pub struct Algorithm { pub random_function: &'static dyn Fn(u32) -> String, } -pub const ALGS: [Algorithm; 5] = [ +pub const ALGS: [Algorithm; 6] = [ Algorithm { id: "letters", version: "0.2", @@ -33,6 +35,13 @@ pub const ALGS: [Algorithm; 5] = [ lang: "eng", random_function: &random_english_words, }, + Algorithm { + id: "hard", + version: "0.1", + description: "hard english words to type", + lang: "english", + random_function: &random_hard_english_words, + }, Algorithm { id: "sentences", version: "0.1",