Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

solving knowledge puzzles

Someone on a mailing list at work forwarded one of those logic puzzles that involve information being revealed by not knowing. Briefly: two numbers in [2,100] are chosen; A is told their product, B is told their sum; A says they don't know the numbers, B says they knew that fact and they also don't know the numbers; and with that knowledge A now knows the numbers.

It turns out that McCarthy wrote a paper: Formalization of two Puzzles Involving Knowledge on solving these puzzles in code.

And based on that, here's a Haskell solution to the problem that is quite nice -- ~20 lines of rather straightforward code. (On the other hand, I imagine that this is the sort of thing a logic programming language is more appropriate for.)
Tags: go read, haskell
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 11 comments