1
0
mirror of https://gitlab.com/MisterBiggs/wordle-rs.git synced 2025-06-15 21:46:41 +00:00

Initial commit

This commit is contained in:
Anson Biggs 2022-02-06 14:44:20 -07:00
commit 23832f21b1
5 changed files with 279559 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "wordlers"
version = "0.1.0"

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "wordlers"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

45
src/main.rs Normal file
View File

@ -0,0 +1,45 @@
use std::fs;
fn main() {
let words = fs::read_to_string("./wordle.txt")
.expect("Cannot read file.")
.split('\n')
.filter(|&word| word.len() == 5)
.map(|word| word.to_owned())
.collect::<Vec<String>>();
let needed = "def";
let banned = "abc";
for word in words {
if check_valid(&word, needed, banned) {
println!("{}", word);
}
}
}
fn check_valid(word: &String, needed: &str, banned: &str) -> bool {
check_banned(word, banned) && check_needed(word, needed)
}
fn check_banned(word: &String, banned: &str) -> bool {
for b in banned.chars() {
if word.contains(b) {
return false;
}
}
return true;
}
fn check_needed(word: &String, needed: &str) -> bool {
needed
.chars()
.filter(|&n| word.contains(n))
.collect::<String>()
.len()
== 5
}
// fn word_value(word: &str) -> usize {
// todo!()
// }

279498
wordle.txt Normal file

File diff suppressed because it is too large Load Diff