mirror of
https://gitlab.com/MisterBiggs/wordle-rs.git
synced 2025-06-16 05:56:39 +00:00
Initial commit
This commit is contained in:
commit
23832f21b1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal 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
8
Cargo.toml
Normal 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
45
src/main.rs
Normal 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
279498
wordle.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user