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

Home > Numbers
A Realmebon Problem (Posted on 2006-11-11) Difficulty: 3 of 5
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.)
Solution re: brute force Comment 2 of 2 |
(In reply to brute force by JLo)

Yes, computers are so fast. I had assumed no leading zeros:

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

100213
150244
410244
500213
550100
 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

000000
000001
010100
100213
150244
410244
500213
550100
 8

  Posted by Charlie on 2006-11-11 16:21:02
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (17)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information