Zip
This commit is contained in:
parent
810b17894d
commit
53c4c680d1
|
|
@ -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"
|
||||
|
|
|
|||
20
src/main.rs
20
src/main.rs
|
|
@ -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();
|
||||
|
|
|
|||
Reference in New Issue