Message Boards Message Boards

1
|
10669 Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How to get perfect square from the list element..

Posted 9 years ago

Hi All, I need some help to solve this problem.. Assume you have n=1,2,3,...,15 number. Put them in an order so that when you add two successive number you get perfect square. As seen one example below. 9+7=16, 7+2=9, 2+14=16, and so on. I did this using pen and paper work.. I tried to solve this using Mathematica. First I got a set of number that make each number perfect square.. But I don't know what should be next step. I tried to use graph but it takes time and is easy to make error (has not been completed yet). I also want to extend it to say n=25.. Any help appreciated. Thanks..

when n=15---->9-7-2-14-11-5-4-12-13-3-6-10-15-1-8

when n=16----> 16-9-7-2-14-11-5-4-12-13-3-6-10-15-1-8

when n=17----> 16-9-7-2-14-11-5-4-12-13-3-6-10-15-1-8-17

when n=18----> no sequences

when n=19----> no sequences

when n=20----> I claimed no sequences

It Must start with 18 since there is only one number make it perfect square namely 7. 18+7 but after this we have two options. 18+7+2 or 18+7+9

Please see attachment..

Attachments:
POSTED BY: Okkes Dulgerci
9 Replies
Posted 9 years ago

Awesome Dent!!. Thanks a lot you all..

POSTED BY: Okkes Dulgerci
Posted 9 years ago

Hi John,

I forgot to mention that numbers cannot repeat and a sequence must contain all n. But I'll check it again maybe there is another combination..

POSTED BY: Okkes Dulgerci
Anonymous User
Anonymous User
Posted 9 years ago

New phone still learning how to use it Sorry trying one more time

Attachments:
POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 9 years ago

Sorry wrong pic See better pic attached

Attachments:
POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 9 years ago

Might this work For n=17----> 16-9-7- 2- 14-11- 5- 4-12- 13- 3-6-10- 15- 1- 8-8......... Then you Get n=18----->16-9-7- 2- 14-11- 5- 4-12- 13- 3-6-10- 15- 1- 8-8-17 Please see attached pic of a analysis I used sorting this out. In this analysis is seen a pattern and how extending that pattern can become a calculator generating next a term iteratively. depicted in the pic and shown are several elements generated past 8-8-17 utilizing this method

Attachments:
POSTED BY: Anonymous User
Posted 9 years ago
POSTED BY: Okkes Dulgerci
Posted 9 years ago
POSTED BY: Paul Cleary
POSTED BY: Udo Krause

Doing so, a little rebuild of Paul's code gives

Clear[dulgerciSquareSequence]
dulgerciSquareSequence[n_Integer] := 
 Module[{b = Subsets[Range[n], {2}], s, ns, o, g, g1, c, p,  bFound = False},
   s = Select[b, IntegerQ[Sqrt[Plus @@ #]] &];
   ns = Complement[b, s];
   (* try every from the ns non-square vertices *)
   For[o = 1, o <= Length[ns], ++o,
    g = Graph[Join[s, {ns[[o]]}]];
    g1 = UndirectedGraph[g];
    c = FindHamiltonianCycle[g1];
    If[Length[c] > 0,
     bFound = True;
     c = ToString /@ Flatten[c];
     c = StringReplace[c, "\[UndirectedEdge]" .. -> ","];
     p = DeleteDuplicates[Flatten[StringCases[c, RegularExpression["\\d+"]]]];
     (* should cut the non-square vertex *)
     Print[p]
     ]
    ];
   If[! bFound, Print["No sequence found for n = ", n]]
   ] /; n > 5

lets test this

dulgerciSquareSequence[15]
{1,15,10,6,3,13,12,4,5,11,14,2,7,9 | 8}

this is your solution for n=15 in reverse order: 9+8=17, here is the split.

dulgerciSquareSequence[16]    
{1,15,10,6,3,13,12,4,5,11,14,2,7,9,16 | 8}

dulgerciSquareSequence[17]
{1,15,10,6,3,13,12,4,5,11,14,2,7,9,16 | 17,8}

dulgerciSquareSequence[18]
No sequence found for n = 18

dulgerciSquareSequence[19]
No sequence found for n = 19

dulgerciSquareSequence[20]
No sequence found for n = 20

dulgerciSquareSequence[21]
No sequence found for n = 21

dulgerciSquareSequence[22]
No sequence found for n = 22

dulgerciSquareSequence[23]
{1,3,22,14,11,5,20,16,9,7,18 | 2,23,13,12,4,21,15,10,6,19,17,8}
{1,3,22,14,11,5,20,16,9 | 18,7,2,23,13,12,4,21,15,10,6,19,17,8}
{1,3,22 | 18,7,9,16,20,5,11,14,2,23,13,12,4,21,15,10,6,19,17,8}

dulgerciSquareSequence[24]
No sequence found for n = 24

dulgerciSquareSequence[25]
{1,3,22,14,11,25,24,12,13,23,2 | 18,7,9,16,20,5,4,21,15,10,6,19,17,8}
{1,24,25,11,5,20,16,9,7,18 | 3,22,14,2,23,13,12,4,21,15,10,6,19,17,8}
{1,3,22,14,2,23,13,12,24,25,11,5,20,16,9,7,18 | 4,21,15,10,6,19,17,8}
{1,3,22,14,2,23,13,12,4,21,15,10,6,19,17,8 | 18,7,9,16,20,5,11,25,24}
{1,3,22,14,11,25,24,12,13,23,2,7,18 | 9,16,20,5,4,21,15,10,6,19,17,8}
{1,8,17,19,6,3,22,14,2,23,13,12,4,21,15,10 | 18,7,9,16,20,5,11,25,24}
{1,3,22,14,2,23,13,12,24,25,11 | 18,7,9,16,20,5,4,21,15,10,6,19,17,8}
{1,3,22,14,2,23,13 | 18,7,9,16,20,5,11,25,24,12,4,21,15,10,6,19,17,8}
{1,3,13,23,2,14,22 | 18,7,9,16,20,5,11,25,24,12,4,21,15,10,6,19,17,8}
{1,8,17,19,6,10,15,21,4,12,13,3,22,14,2,23 | 18,7,9,16,20,5,11,25,24}

the 18 is the at one end of a sequence.

There are many solutions for 25 < n < 32. So experimentally the situation is clear (mod errors).

POSTED BY: Udo Krause
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