This commit is contained in:
Dandaedre 2025-09-15 02:40:25 +02:00
parent 810b17894d
commit 53c4c680d1
2 changed files with 20 additions and 7 deletions

View File

@ -6,3 +6,10 @@ edition = "2024"
[dependencies]
clap = { version = "4.5.47", features = ["derive"] }
regex = "1.11.2"
[profile.release]
opt-level = "z"
strip = true
lto = true
codegen-units = 1
panic = "abort"

View File

@ -2,9 +2,10 @@
// Struct record plus hash ?
// Letter frequency as weight
// find better weight
#![allow(dead_code)]
// #![allow(dead_code)]
use clap::Parser;
use regex::Regex;
use std::fmt::Display;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
@ -30,8 +31,6 @@ struct Args {
out: Option<String>,
}
use std::{fmt::Display, fs::read_to_string};
#[derive(Debug, Eq, PartialEq, Clone)]
struct Word {
origin: String,
@ -89,6 +88,7 @@ impl Weightlist {
self.weights[c as usize - 'a' as usize] = val;
}
#[allow(dead_code)]
fn getid(&self, id: usize) -> isize {
self.weights[id]
}
@ -107,13 +107,19 @@ impl Weightlist {
}
}
fn read_list(path: &str) -> Vec<Word> {
read_to_string(path)
.unwrap()
fn load_words() -> Vec<Word> {
String::from_utf8_lossy(include_bytes!("../wordlists/final.txt"))
.split("\n")
.map(|s| s.into())
.collect()
}
// fn read_list(path: &str) -> Vec<Word> {
// read_to_string(path)
// .unwrap()
// .split("\n")
// .map(|s| s.into())
// .collect()
// }
#[derive(Debug, Clone)]
struct Wordlist {
@ -244,7 +250,7 @@ fn backtrack_best(
}
}
fn main() {
let wl = Wordlist::new(read_list("./wordlists/final.txt"));
let wl = Wordlist::new(load_words());
let weights = wl.make_weights();
let args = Args::parse();