During our review process I composed the following listing using QuickBasic. Variable 'pp' was provided to avoid "wide scale" edits. 'm' was provide only for the purpose of screen display.
I had an issue of seeking to overcome "0^0", or 0º, which I ultimately resolved that with the If statements.
The program displayed three results, for sum1 - sum2, 0,0; 1;1 and 3435,3435. As 0º has no relevance, and "1" has been ruled out by the problem text the only valid result found is 3435.
I note Charlie has been instructive as to why this value is unique.
Incidentally, the "time$" variable (one of which has been deleted) showed a runtime of some 100 minutes in processing the 10^9 For...next loops.
I'm not claiming this as my solution as I was aware of pcbouhid's value before hand; I actually set out to see if there was a unique solution as defined by the problem.CLS
pp = 9
m = 2
FOR g = 0 TO pp
IF g = 0 THEN z = 0 ELSE z = g ^ g
FOR f = 0 TO pp
IF f = 0 THEN y = 0 ELSE y = f ^ f
FOR e = 0 TO pp
IF e = 0 THEN x = 0 ELSE x = e ^ e
FOR d = 0 TO pp
IF d = 0 THEN w = 0 ELSE w = d ^ d
FOR c = 0 TO pp
IF c = 0 THEN v = 0 ELSE v = c ^ c
FOR b = 0 TO pp
IF b = 0 THEN u = 0 ELSE u = b ^ b
FOR a = 0 TO pp
IF a = 0 THEN t = 0 ELSE t = a ^ a
sum1 = g * 10 ^ 6 + f * 10 ^ 5 + e * 10 ^ 4 + d * 10 ^ 3 + c * 10 ^ 2 + b * 10 + a
sum2 = z + y + x + w + v + u + t
IF sum1 = sum2 THEN
LOCATE 2 + m: PRINT sum1; sum2; TIME$
m = m + 1
END IF
NEXT: NEXT: NEXT: NEXT: NEXT: NEXT: NEXT
|
Posted by brianjn
on 2008-11-15 20:48:36 |