You are viewing a single comment's thread from:

RE: Two wise men and two number (solution explained)

in #steemstem6 years ago

There is a mistake in my explanation. I apologize for that. This part is not quite correct:

So we need to split each of these sums into all possible term pairs, multiply the pairs and remove those products which we encounter more than once. It happens that the only product we will be left after removal is 52.

Actually, there are more products which we will encounter only once, e. g. 18. But they won't serve as the right solution, because it is not a sufficient condition. We need to select a sum which has a single decomposition to terms which product factorization give us a unique pair of numbers whose sum is in on our list.

This is quite complicated so I present it in the form of pseudo-code for better understanding:

For each sum from our list:

  1. Decompose it into a pair of terms in all possible ways
  2. For each pair of terms:
    2.1. Calculate their product
    2.2. Factorize the product into a pair of factors in all possible ways
    2.3. For each pair of factors calculate their sum
    2.4. If only one of these sums is in our list, then mark the product as a potentially good one (this condition allows Gandalf to know the numbers).
  3. If only one of the products is marked as a potentially good, that is the right product and the right sum (only this condition allows Saruman to know the numbers).
  4. Otherwise start over with the next item from the list.

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.033
BTC 94693.28
ETH 3119.47
USDT 1.00
SBD 3.05