Ten Digits and Two Squares

A math wizard has a bag containing the digits 0 through 9, and he has used six of them to stick two different three-digit perfect squares on the foreheads of Ann and Ben. Both Ann and Ben know this fact, but each person can see the other person's number only. The wizard asks Ann: "How many of the digits remaining in my bag can you exactly tell me?"
  1. Ann replies: "Three." The wizard then asks Ben same question. What should he reply, and why?
  2. Ann replies: "Two." Ben then says: "I know my number." There are 3 possible numbers on Ben's forehead: what are they? And what are the numbers in the bag?

Source: 1. DansMath #158 and Sudipta Das, 2. Denis Borris


Solutions were received from Al Zimmermann, Susan Hoover, Jayavel Sounderpandian, Claudio Baiocchi, Paul Botham, Toby Gottfried, Vikram Chandrasekhar, Adrian Atanasiu, David Bachtel. Al Zimmermann's solution follows:
There are 22 3-digit squares (10² through 31²).

Of these 22, 13 do not use the same digit more than once:
(169, 196, 256, 289, 324, 361, 529, 576, 625, 729, 784, 841, 961).

From these 13, you can choose 20 pairs that have no digits in common:
     (169, 324), (169, 784), (196, 324), (196, 784),
     (256, 784), (256, 841), (289, 361), (289, 576),
     (324, 576), (324, 961), (361, 529), (361, 729),
     (361, 784), (529, 784), (529, 841), (576, 841),
     (625, 784), (625, 841), (729, 841), (784, 961).

> 1. Ann replies: "Three." The wizard then asks Ben
>    same question. What should he reply, and why?

If Ann                                         Digits in the
sees this                                      wizard's bag
on Ben     She knows she could have            she would know
-------------------------------------------------------------
169        324, 784                            0, 5
196        324, 784                            0, 5
256        784, 841                            0, 3, 9
289        361, 576                            0, 4
324        169, 196, 576, 961                  0, 8
361        289, 529, 729, 784                  0
529        361, 784, 841                       0
576        289, 324, 841                       0
625        784, 841                            0, 3, 9
729        361, 841                            0, 5
784        169, 196, 256, 361, 529, 625, 961   0
841        256, 529, 576, 625, 729             0, 3
961        324, 784                            0, 5

If Ann claims to know exactly 3 digits remaining in the wizard's bag,
then Ben must be wearing either 256 or 625.  These two numbers have the
same digits, so Ben now knows his own digits as well as those he sees
Ann wearing.  So he know all 4 digits in the wizard's bag.

> 2. Ann replies: "Two." Ben then says: "I know my number."
>    There are 3 possible numbers on Ben's forehead: what
>    are they? And what are the numbers in the bag?

Since Ann announced she knows exactly two digits in the wizard's bag,
Ben must know that he's wearing either 169, 196, 289, 324, 729, 841 or 961.

If Ben sees
this on Ann       He knows he could be wearing
----------------------------------------------
169               324
196               324
256               841
289               
324               169, 196, 961
361               289, 729
529               841
576               289, 324, 841
625               841
729               841
784               169, 196, 961
841               729
961               324

The only three numbers Ben could ever be sure of are 324, 729 and 841.

There doesn't seem to be enough information for us to determine exactly
what's in the wizard's bag.  There are eight possible scenarios, as follows:

     Ann, Ben     Digits left in the bag
     -----------------------------------
     169, 324     0, 5, 7, 8
     196, 324     0, 5, 7, 8
     256, 841     0, 3, 7, 9
     529, 841     0, 3, 6, 7
     625, 841     0, 3, 7, 9
     729, 841     0, 3, 5, 6
     841, 729     0, 3, 5, 6
     961, 324     0, 5, 7, 8

It's not clear to why the guy with the bag of digits is considered a
math wizard.  I think the math wizards are Ann and Ben.  The guy with
the bag seems more like Vanna White.

Mail to Ken