commit 5407819e528a5453cd31285eb820061df38619e0
parent 1187bd34f090f8fc5bb79ed7b06df12fbc785576
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 30 Mar 2023 02:12:31 -0700
cleanup
Diffstat:
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/lechatphp/mod.rs b/src/lechatphp/mod.rs
@@ -130,18 +130,12 @@ fn solve_difficulty2(img: &DynamicImage) -> Option<String> {
let mut answer = String::new();
for i in 0..5 {
let sub_img = img.crop_imm(5 + ((8+1)*i), 7, 8, 14);
- 'alphabet_loop: for c in ALPHABET1.chars() {
+ for c in ALPHABET1.chars() {
let good_letter_img = get_letter_img(c);
- for y in 0..14 {
- for x in 0..8 {
- if good_letter_img.get_pixel(x, y) == *ON_COLOR &&
- sub_img.get_pixel(x, y) != *ON_COLOR {
- continue 'alphabet_loop;
- }
- }
+ if img_contains_letter(&sub_img, &good_letter_img) {
+ answer.push(c);
+ break;
}
- answer.push(c);
- break;
}
}
Some(answer)