Discussion:
Mastermind puzzle (with 3 digits)
(too old to reply)
HenHanna
2024-02-25 21:07:49 UTC
Permalink
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!


Loading Image...

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.
Ammammata
2024-02-26 07:57:57 UTC
Permalink
Post by HenHanna
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
042
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........
Phil Carmody
2024-02-27 17:04:58 UTC
Permalink
Dumb x-post removed.
Post by HenHanna
3 digit lock
a) [682]: One number is correct and well-placed
b) [614]: One number is correct but wrongly placed
c) [206]: Two numbers are correct but wrongly placed
d) [738]: Nothing is correct
e) [780]: One number is correct but wrongly placed
d & e =>
f) in [780], 7 and 8 are incorrect, so 0 is wrongly placed

f & c =>
g) in [206], 0 is correct, but wrongly placed, so 0 is in the first position

progress: [0__]

a & b =>
h) 6 cannot be correct as its position doesn't change

h & d =>
i) in [682], 2 is correct, and well-placed

progress: [0_2]

b & h =>
j) in [614], 4 is correct but wrongly placed

solution: [042]

This is not a task for python. Prolog might be a better language if you
desperately want to code an answer rather than using just simple logic,
but surely that's more effort than the above, which is trivial.

Of course, an automated solver could be repurposed into a puzzle
generator. Parametrise the size and the alphabet, and you could probably
generate puzzles that were bordering on the impractical for a human to
solve.

Phil
--
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/
Carl G.
2024-02-27 18:30:03 UTC
Permalink
Post by HenHanna
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
HenHanna
2024-02-27 18:59:44 UTC
Permalink
Post by Carl G.
I currently don't have time to write code (plus I don't write a lot of
Python code), ................
ObPuzzle1: Write a "one-liner" program (in Python, Powershell, Basic
script, etc.), that, although inelegant (even obfuscated :)), finds the solution.
thanks.... i'll try




bard.google.com (now Gemini) can't write Python code that solves this. Can ChatGPT do it?



re: constraint satisfaction problem (CSP)

i have Knuth's book on CSP... i'll check inside.


i studied Prolog when i was younger. (Wrote a Prolog interpreter in Lisp, etc.)


Is this a typical easy exercise in Prolog programming? Could someone share Prolog code for it?
Blue-Maned_Hawk
2024-03-02 22:10:28 UTC
Permalink
Post by HenHanna
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.
My answer: mreb sbyybjrq ol sbhe cerprrqvat gjb frrzf gb zrrg nyy bs gur
erdhverzragf.

Now to see if i was correct…
--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
…assuming i'm understanding things correctly, which i may not be.
HenHanna
2024-03-10 01:07:28 UTC
Permalink
Post by Blue-Maned_Hawk
Post by HenHanna
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.
My answer: mreb sbyybjrq ol sbhe cerprrqvat gjb frrzf gb zrrg nyy bs gur
erdhverzragf.
Now to see if i was correct…
--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
…assuming i'm understanding things correctly, which i may not be.





Here, i can see your XFACE, but...

Your sig seems to contain strange chars.
Loading...