XPost: rec.puzzles.crosswords
On 2/25/2024 1:07 PM, HenHanna wrote:
What's another great problem like this one?
(i just wrote (non-elegant) Python code.)
Could you share a short, VERY Readable Pythonic code that solves this?
Thank you!
https://i.imgur.com/72LGJjj.jpeg
3 digit lock
[682]: One number is correct and well-placed
[614]: One number is correct but wrongly placed
[206]: Two numbers are correct but wrongly placed
[738]: Nothing is correct
[780]: One number is correct but wrongly placed
HINT -- A mark of a great puzzle, this one contains a surprise or two.
I currently don't have time to write code (plus I don't write a lot of
Python code), but I would suggest writing a Boolean function that takes
the test number, a "correct and correctly placed" count, and a "correct,
but wrongly placed" count, for arguments and returns "True" when the
clue conditions are met, "False" otherwise. Then call the function
within a loop that cycles over all allowed numbers and checks if all
conditions are met for each number. It may not be any more "elegant"
than the code you wrote, but it could be easily adapted for other
problems (different clues, only test for digits 0 to 4, etc.) The code
could be made very readable, especially if clues are each on their own
line. If letters were used instead of digits, the function would not be limited to ten values. The function could also be used as a tool to
create similar puzzles by looking for clue-sets that yield unique
solutions.
ObPuzzle1: Write a "one-liner" program (in Python, Powershell, Basic
script, etc.), that, although inelegant (even obfuscated :)), finds the solution.
ObPuzzle2: How many five-clue "clue-sets" for 3-digit numbers (like the example) have an unique solution? The clues could be 0 to 3 "correct
and well-placed, 0 to 3 "correct but wrongly-placed" (up to 3 "correct").
--
Carl G.
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)