I gave my niece and nephew the following puzzler:
A: Draw a 3x3 grid, with the boxes labeled 1 through 9 in the usual order (left to right; top to bottom).
B:For each of the following instructions you must write a number, greater than 10, starting in one box and going across (left to right) or down, with one digit to each box. Your answers should fill the grid, with no two answers overlapping.
C:Starting with a box whose number is a square, write a square number.
D:Starting with a box whose number is a cube, write a cube number.
E:Starting in a box whose number is prime, write a prime number whose digits add up to an even number.
F:Starting with a box whose number is even, write an even number
Unfortunately, one of the copies of my instructions had part F completely missing. Each child turned in a 3x3 grid which was correct for the version they had been given. By coincidence, they turned in identical grids.
How did they fill out their grids?
The following program tests all sets of 3-digit cube in the first row, square in the second row and prime in the third, against each of the 4-clue formats mentioned in my previous post.
5 open "cluels2.txt" for output as #2
10 for CBase=5 to 9
20 Cube=CBase*CBase*CBase
30 for SBase=10 to 31
40 Square=SBase*SBase
50 Prime=2
60 while Prime<100
70 Prime=nxtprm(Prime)
80 wend
90 while Prime<1000
100 A$=cutspc(str(Cube))
110 B$=cutspc(str(Square))
120 C$=cutspc(str(Prime))
130 VSq=val(left(A$,1)+left(B$,1)+left(C$,1))
135 Sr=int(sqrt(VSq)+0.5)
140 Even=val(mid(A$,2,2))
150 Pr2=val(mid(B$,2,2))
160 Cu2=val(mid(C$,2,2))
165 Cr=int(Cu2^(1/3)+0.5)
168 if Pr2>1 then
170 :if Even@2=0 and nxtprm(Pr2-1)=Pr2 and Cr*Cr*Cr=Cu2 then
175 :if Sr*Sr=VSq then
179 :print#2, "Vert Sq 3"
180 :print#2, A$:print#2, B$:print#2, C$:print#2,
230 VSq=val(left(B$,1)+left(C$,1))
235 Sr=int(sqrt(VSq)+0.5)
240 Pr2=val(mid(B$,2,1)+mid(C$,2,1))
250 Even=val(mid(B$,3,1)+mid(C$,3,1))
268 if Pr2>1 then
270 :if Even@2=0 and nxtprm(Pr2-1)=Pr2 then
275 :if Sr*Sr=VSq then
279 :print#2, "Hor cube (orig)"
280 :print#2, A$:print#2, B$:print#2, C$:print#2,
330 VSq=val(left(A$,1)+left(B$,1)+left(C$,1))
335 Sr=int(sqrt(VSq)+0.5)
340 Even=val(mid(A$,2,1)+mid(B$,2,1))
350 Pr2=val(mid(A$,3,1)+mid(B$,3,1))
360 Cu2=val(mid(C$,2,2))
365 Cr=int(Cu2^(1/3)+0.5)
368 if Pr2>1 then
370 :if Even@2=0 and nxtprm(Pr2-1)=Pr2 and Cr*Cr*Cr=Cu2 then
375 :if Sr*Sr=VSq then
379 :print#2, "Vert Sq 3*"
380 :print#2, A$:print#2, B$:print#2, C$:print#2,
430 VSq=val(left(B$,1)+left(C$,1))
435 Sr=int(sqrt(VSq)+0.5)
440 Pr2=val(mid(B$,2,2))
450 Even=val(mid(C$,2,2))
468 if Pr2>1 then
470 :if Even@2=0 and nxtprm(Pr2-1)=Pr2 then
475 :if Sr*Sr=VSq then
479 :print#2, "Hor cube (orig)*"
480 :print#2, A$:print#2, B$:print#2, C$:print#2,
530 HSq=val(A$)
535 Sr=int(sqrt(HSq)+0.5)
540 Pr2=val(mid(B$,2,2))
550 Even=val(mid(B$,1,1)+mid(C$,1,1))
560 Cu2=val(mid(C$,2,2))
565 Cr=int(Cu2^(1/3)+0.5)
568 if Pr2>1 then
570 :if Even@2=0 and nxtprm(Pr2-1)=Pr2 then
575 :if Sr*Sr=HSq and Cr*Cr*Cr=Cu2 then
579 :print#2, "Hor square (orig cube)"
580 :print#2, A$:print#2, B$:print#2, C$:print#2,
1295 Prime=nxtprm(Prime)
1300 wend
1310 next
1320 next
The check did not include that the prime numbers consist of digits that add up to an even number, and so produced several more results than just those that meet the full criteria. But inspection of the output shows two cases where the prime numbers' digits each added up to an even number:
Vert Sq 3*
125
289
101
Vert Sq 3*
125
289
127
In the first instance, the 2-digit cube beginning in square 8 has a leading zero, and is presumed disallowed. That leaves the second one shown.
So one of the children had 125 as the cube, 289 as the square and 127 as the prime. The other had 121 as the square, 28 as the even number, 59 as the prime and 27 as the cube.
|
Posted by Charlie
on 2005-03-14 20:49:54 |