Last active
February 27, 2024 07:33
-
-
Save DLotts/4fc8e49aa3298052c837cc4e6e3bab0f to your computer and use it in GitHub Desktop.
Rust to Solve Nerdle puzzle where you know digits available and an operation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solve Nerdle puzzle where you know digits available and an operation. | |
// in this case '3', '4', '8' are red or not tied yet | |
// and got green on equals, division and z: abc/zz=x | |
// This could also solve x*zz=abc | |
fn main() { | |
let use_digits = vec!['3', '4', '8']; | |
// Try every two digit xy | |
for xy in [3, 4, 8] { | |
for z in 33..88 { | |
let abc = xy * z; | |
// Check for only available digits in abc and xy | |
if (abc.to_string() + &(xy.to_string())) | |
.chars() | |
.all(|d| use_digits.contains(&d)) | |
{ | |
println!("A solution is: {abc}/{z}={xy}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment