better scoring
This commit is contained in:
parent
3b0283df56
commit
fd49c952b0
|
|
@ -6,8 +6,13 @@ pub fn score(plaintext: &Vec<u8>) -> u32 {
|
||||||
let mut score = 0;
|
let mut score = 0;
|
||||||
|
|
||||||
for ch in plaintext.iter() {
|
for ch in plaintext.iter() {
|
||||||
if ch >= &97 && ch <= &122 {
|
if ch >= &0x20 && ch <= &0x7e {
|
||||||
score += ranking[(ch - 97) as usize];
|
score += 1;
|
||||||
|
if ch >= &('a' as u8) && ch <= &('z' as u8) {
|
||||||
|
score += ranking[(ch - 'a' as u8) as usize];
|
||||||
|
} else if ch >= &('A' as u8) && ch <= &('Z' as u8) {
|
||||||
|
score += ranking[(ch - 'A' as u8) as usize];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
score
|
score
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue