Message Boards Message Boards

0
|
1502 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

General solution of longest arrangement problem

Posted 2 years ago

I'm trying to find the general solution of a problem, and I guess is of the kind "longest paths in directed graphs with cycles": consider all the square numbers with exactly n digits, I want to arrange them such that the last digit of a square is equal to first digit of the next square and find the longest arrangement, how many elements contain and possibly how many of those longest arrangement are possible. Of course some squares will be sorted out: at most 1 square can start with {2,3,7,8} and if so, must be in the 1st position; at most 1 square with 0 as last digit.

For n=2 the squares are {16, 25, 36, 49, 64, 81}. So the longest arrangement is {81, 16, 64, 49} with s=4 elements

For n=3 there are s=12 elements in the longest arrangement, and one of the them (there are 26 in total) is:

{841, 121, 144, 484, 441, 169, 961, 196, 676, 625, 529, 900}

I asked for help here https://mathematica.stackexchange.com/questions/265002/longest-arrangement-of-n-digit-square-numbers-s-t-last-digit-equals-first-digit/265019 , hoping to use Mathematica to brute force the solutions, and I received some great and highly detailed answers, but when I try with n=4 the algorithm slows down. I guess, but I'm not sure, that the answer for n=4 is s=30 and one of the arrangement is:

{2025, 5776, 6561, 1225, 5625, 5041, 1369, 9801, 1024, 4624, 4489, 9216, 6084, 4761, 1521, 1764, 4356, 6889, 9604, 4225, 5329, 9409, 9025, 5184, 4096, 6241, 1681, 1156, 6724, 4900}

For n = 5 the longest arrangement I found is this, s= 93:

{39204, 47089 ,97344, 46225, 53824, 41616, 66564, 42025, 51984, 43681, 12544, 48841,13225, 52441, 18225, 58081, 10609, 96721, 10404, 45369, 93025, 56644, 47524, 41209, 91809, 93636, 62001, 10816, 65536, 67081, 16641, 10201, 12321,14641, 19321, 13689, 98596, 66049, 95481, 17161, 15129, 94864, 44944, 43264, 47961, 18496, 63504, 49729, 94249, 90601, 13456, 64009, 99225, 53361, 15625, 55696, 69696, 68121, 14161, 11881, 19881, 18769, 97969, 99856, 61009, 92416, 60516, 60025, 57121, 11025, 55225, 50625, 58564, 42436, 68644, 40401, 14884, 45796, 63001, 11664, 46656, 65025, 51076, 69169, 91204, 44521, 17956, 64516, 61504, 40804, 49284, 42849, 96100} with s=93

So, do you know how can I calculate how many elements are in the longest chain of squares with n digits?

Thank you

POSTED BY: Gennaro Rossi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract