All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 A Realmebon Problem (Posted on 2006-11-11)
In the planet Realmebon, the inhabitants use base 6 in their daily transactions. One of the inhabitants noticed that if he split his 6-digit ID number into two 3-digit numbers and squared each of them, their sum would equal his ID number.

How many possible ID numbers could he have been assigned, and what are they?

 See The Solution Submitted by K Sengupta Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: brute force Comment 2 of 2 |
(In reply to brute force by JLo)

DEFDBL A-Z
DECLARE FUNCTION dec (h\$)
DECLARE FUNCTION b6\$ (d)
low = dec("100000")
high = dec("555555")
FOR i = low TO high
chk\$ = b6(i)
c1\$ = LEFT\$(chk\$, 3)
c2\$ = RIGHT\$(chk\$, 3)
a = dec(c1\$): b = dec(c2\$)
c\$ = b6(a * a + b * b)
IF c\$ = chk\$ THEN PRINT c\$: ct = ct + 1
NEXT
PRINT ct

FUNCTION b6\$ (d)
s\$ = ""
r = d
DO
dig = r MOD 6
r = r \ 6
s\$ = LTRIM\$(STR\$(dig)) + s\$
LOOP UNTIL r = 0
b6\$ = s\$
END FUNCTION

FUNCTION dec (h\$)
t = 0
FOR i = 1 TO LEN(h\$)
d\$ = MID\$(h\$, i, 1)
t = t * 6 + VAL(d\$)
NEXT
dec = t
END FUNCTION

`100213150244410244500213550100 5`

finding an answer of 5.  But if you set low to 0 instead, you get

DEFDBL A-Z
DECLARE FUNCTION dec (h\$)
DECLARE FUNCTION b6\$ (d)
low = 0
high = dec("555555")
FOR i = low TO high
chk\$ = b6(i)
c1\$ = LEFT\$(chk\$, 3)
c2\$ = RIGHT\$(chk\$, 3)
a = dec(c1\$): b = dec(c2\$)
c\$ = b6(a * a + b * b)
IF c\$ = chk\$ THEN PRINT c\$: ct = ct + 1
NEXT
PRINT ct

FUNCTION b6\$ (d)
s\$ = ""
r = d
DO
dig = r MOD 6
r = r \ 6
s\$ = LTRIM\$(STR\$(dig)) + s\$
LOOP UNTIL r = 0
IF LEN(s\$) < 6 THEN s\$ = RIGHT\$("000000" + s\$, 6)
b6\$ = s\$
END FUNCTION

FUNCTION dec (h\$)
t = 0
FOR i = 1 TO LEN(h\$)
d\$ = MID\$(h\$, i, 1)
t = t * 6 + VAL(d\$)
NEXT
dec = t
END FUNCTION

`000000000001010100100213150244410244500213550100 8`

 Posted by Charlie on 2006-11-11 16:21:02

 Search: Search body:
Forums (0)
Random Problem
Site Statistics
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox: