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

Home > Numbers
Celebrity Squares (Posted on 2011-03-29) Difficulty: 3 of 5

Three different 5-digit perfect squares between them use five different digits. No two of these squares share a common first digit, nor a common last digit. Each of the five digits is used a different number of times, the five numbers of times being the same as the five digits of the perfect squares. At least 3 digits are used their own number of times. What are the three squares? (Theme suggested by New Scientist, March 2011)

See The Solution Submitted by broll    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) | Comment 1 of 2

This program finds those 5-digit squares which use only the digits 1 through 5, as the sum of the integers 1 through 5 is 15, which is precisely the number of digits needed for three 5-digit numbers.

CLS
FOR n = 100 TO 316
  nsq = n * n
  s$ = LTRIM$(STR$(nsq))
  good = 1
  FOR i = 1 TO 5
   IF MID$(s$, i, 1) > "5" OR MID$(s$, i, 1) < "1" THEN good = 0
  NEXT
  IF good THEN PRINT n, nsq
NEXT

The 5-digit squares appear to the right of their square roots:

 111           12321
 112           12544
 115           13225
 182           33124
 185           34225
 188           35344
 211           44521
 229           52441
 235           55225
 
Making the program go farther (with the hindsight that there are only a manageable nine such squares):

 

CLS
FOR n = 100 TO 316
  nsq = n * n
  s$ = LTRIM$(STR$(nsq))
  good = 1
  FOR i = 1 TO 5
   IF MID$(s$, i, 1) > "5" OR MID$(s$, i, 1) < "1" THEN good = 0
  NEXT
  IF good THEN PRINT n, nsq: ct = ct + 1: sq$(ct) = LTRIM$(STR$(nsq))
NEXT
PRINT

FOR a = 1 TO ct - 2
 as$ = sq$(a)
FOR b = a + 1 TO ct - 1
 bs$ = sq$(b)
FOR c = b + 1 TO ct
 good = 1
 cs$ = sq$(c)
 IF LEFT$(as$, 1) = LEFT$(bs$, 1) OR LEFT$(as$, 1) = LEFT$(cs$, 1) OR LEFT$(bs$, 1) = LEFT$(cs$, 1) THEN good = 0
 IF RIGHT$(as$, 1) = RIGHT$(bs$, 1) OR RIGHT$(as$, 1) = RIGHT$(cs$, 1) OR RIGHT$(bs$, 1) = RIGHT$(cs$, 1) THEN good = 0
 REDIM dct(5)
 FOR i = 1 TO 15
   dused = VAL(MID$(as$ + bs$ + cs$, i, 1))
   dct(dused) = dct(dused) + 1
 NEXT
 FOR i = 1 TO 4
 FOR j = i + 1 TO 5
   IF dct(i) = dct(j) THEN good = 0
 NEXT
 NEXT
 IF good THEN PRINT as$: PRINT bs$: PRINT cs$: PRINT
NEXT
NEXT
NEXT

adds to the output the candidate sets of three squares based on non-repeated first digits and non-repeated last digits, as well as having a different number of each digit:


12544
34225
44521

12544
34225
52441

35344
44521
55225

Only in the last of these, seen by inspection, do three of the digits appear their own number of times: one 1, four 4's and five 5's.


  Posted by Charlie on 2011-03-29 15:44:16
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
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