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

Home > Numbers
Square Rearranger (Posted on 2023-12-06) Difficulty: 3 of 5
Find the smallest three distinct whole numbers A, B and C such that you can rearrange the digits of A and B to get C^2, the digits of A and C to get B^2, and the digits of B and C to get A^2.

**** Leading zeroes are not allowed.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts ideas ... | Comment 1 of 25
I started with a brute force program to check values for A,B,C up to 1000 but it was very slow on my system using Python.

My next thought is to build up a dictionary where the keys are the integers, say, N, and each value is a list of sets; each set has two elements; the elements are all ways of splitting the digits of N^2 to form two numbers.   Consider 16^2 = 256, for example.  Its dictionary entry would be:
{16: [{2, 56}, {2, 65}, {5, 26}, {5, 62}, {6, 25}, {6, 25}]}
The search to find the solution would be first generate these entries, not trivial for larger N.
And then to check each element of each 2-element set, {5, 26} for example to see if the other 2 members of the possible triplet are present elsewhere in the dictionary; ie a success would look like: 
{5: [ ...., {16,26}, .... ] }
{26: [ ...., {5,16}, .... ] }

(sets because {a,b} is the same as {b,a})
Python uses curly braces {} both to signify a dictionary and a set.

I think this would be faster than brute force; but I haven't thought this part through fully.

  Posted by Larry on 2023-12-06 19:01:37
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 (10)
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