Hacker News new | ask | show | jobs
by at_a_remove 1499 days ago
Well, so they brute-force and come up with a set of possible answers, a list of tuples.

I don't have any guarantees that both of them are sorting each list the same. So how does "I don't have enough information" relay which of those list items to eliminate?

1 comments

They always eliminate the pairs of products/sums with only one possible pair (think a sum to possible pairs and a product to possible pairs list).

When the person knowing the product says he doesn't know the answer, the sum person now checks the product list for all products with only 1 pair. These pairs can now be removed from the sum and product list. That actually culls the sum list and some entries that previously had 2 or more options now have 1 less. If the entry for the known sum has only 1 pair, he knows the answer. Otherwise he doesn't and now the culling continues with all sums that have only 1 pair. Repeat until you have the solution.

No ordering required. The algorithm can terminate at different rounds depending on the picked number and for some N (like 4) might not have a solution at all! For the given riddle the exact turn the solution was found is given through the conversation.

This is a pretty neat explanation https://alexanderell.is/posts/numbers-game/