# Using GAP to produce solutions to Pentultimate

I recently got started using GAP, and wrote a C++ program that generates legal scrambles in cyclic-notation for GAP, and some GAP code that gives solutions to them using the "PreimageRepresentative" function. On short scrmables, it can produce the reverse turns to solve it (likely optimal). But for a random scramble of say 500 turns it produces solutions over 14000 turns (in the analog of QTM or 'word-length' in the freegroup). This is not satisfactory to me because I can solve it by hand using less than 1000 turns doing centers-first.

You can play with this puzzle here (it doesn't physically exist yet): http://users.skynet.be/gelatinbrain/Applets/Magic%20Polyhedra/dodeca_f6.htm

Just to give some backstory... Initally, I used GAP to find solutions to twisting two corners on on a layer, by giving it only one sequence (alg) and a particular single turn - which worked out great for endgame stuff.

Anyways, the final full pentultimate code I have:
====
fullpent := Group( (20,30,40,50,60)(11,12,13,14,15)(21,31,41,51,61)(22,32,42,52,62)(23,33,43,53,63)(25,35,45,55,65)(121,111,101,91,81), (10,60,80,120,30)(21,22,23,24,25)(11,65,85,121,32)(12,61,81,122,33)(13,62,82,123,34)(15,64,84,125,31)(51,95,75,112,42), (10,20,120,110,40)(31,32,33,34,35)(12,25,125,111,42)(13,21,121,112,43)(14,22,122,113,44)(11,24,124,115,41)(61,85,74,102,52), (10,30,110,100,50)(41,42,43,44,45)(13,35,115,101,52)(14,31,111,102,53)(15,32,112,103,54)(12,34,114,105,51)(21,125,73,92,62), (10,40,100,90,60)(51,52,53,54,55)(14,45,105,91,62)(15,41,101,92,63)(11,42,102,93,64)(13,44,104,95,61)(31,115,72,82,22), (10,50,90,80,20)(61,62,63,64,65)(15,55,95,81,22)(11,51,91,82,23)(12,52,92,83,24)(14,54,94,85,21)(41,105,71,122,32) ); t := FreeGroup("a","b","c","d","e","f"); hom := GroupHomomorphismByImages(t,fullpent,GeneratorsOfGroup(t),GeneratorsOfGroup(fullpent)); state := ( ); PreImagesRepresentative(hom,state);
====

I numbered it in a wierd way, using multiples of 10 for the centers, and numbering the corner stickers by the center number and 1-5.

Anyways, some scrambles:
====
state := (10,100,50,80,90,30,120,110,60,20,40)(11,111,64,124,53,42,94,54,15,125,44,81,32,104,52,33,55,73)(12,72,14,25,91,103,61,43,95,74,45,13,71,105,51,112,115,23)(21,93,41,121,63,114,22,35,82,113,101,31,83,92,62,34,102,65)(24,123)(75,122)(84,85);
====
state := (10,110,20,40,120)(11,115,24,41,124)(12,111,25,42,125)(13,112,21,43,121)(14,113,22,44,122)(31,34,32,35,33)(52,74,61,102,85);
====
state := (10,40,30)(11,61,22)(12,41,35)(13,42,31)(14,43,32)(15,34,104,94,92,23,114,75,74,62,112,93,83,105,81,103,84,124,51,125,72,71,54,65,73,123,113)(20,110,90,120,50,60)(21,52,111)(24,115,91,122,44,55,85,102,63)(25,101,82,33,45,95,121,53,64)(80,100)
====

These are 500, 1, and 3 turn scrmables respectively. Okay... now I'm beginning to think I did something wrong, like a typo somewhere, because at 3 turns, it spit out a 31,500 turn solution. I really don't know the capablities of GAP well enough to know if this is typical or not. I need help. The goal is for it to average under 1000 turns.

-Doug

## Comment viewing options

### I needed to add another gener

I needed to add another generator. The turn of the rear face. This combined with turning the front face allows for whole-puzzle rotations which reduce the solution lengths significantly. For completeness I have all 12-generators, half of which are redundant. Using only the first 7, I fix the rear center-sticker and it seems to make GAP happier. I am getting solutions under 2000 now, which is much more reasonable. Using all 12 generators seems to increase the solution length, but I'll play with this. Anyhow, the GAP experts on this board must have some advice for me.

fullpent := Group(
(20,30,40,50,60)(11,12,13,14,15)(21,31,41,51,61)(22,32,42,52,62)(23,33,43,53,63)(25,35,45,55,65)(121,111,101,91,81),
(10,60,80,120,30)(21,22,23,24,25)(11,65,85,121,32)(12,61,81,122,33)(13,62,82,123,34)(15,64,84,125,31)(75,112,42,51,95),
(10,20,120,110,40)(31,32,33,34,35)(12,25,125,111,42)(13,21,121,112,43)(14,22,122,113,44)(11,24,124,115,41)(74,102,52,61,85),
(10,30,110,100,50)(41,42,43,44,45)(13,35,115,101,52)(14,31,111,102,53)(15,32,112,103,54)(12,34,114,105,51)(73,92,62,21,125),
(10,40,100,90,60)(51,52,53,54,55)(14,45,105,91,62)(15,41,101,92,63)(11,42,102,93,64)(13,44,104,95,61)(72,82,22,31,115),
(10,50,90,80,20)(61,62,63,64,65)(15,55,95,81,22)(11,51,91,82,23)(12,52,92,83,24)(14,54,94,85,21)(71,122,32,41,105),
(80,90,100,110,120)(71,72,73,74,75)(82,92,102,112,122)(83,93,103,113,123)(84,94,104,114,124)(85,95,105,115,125)(24,64,54,44,34)#,
#(70,120,20,60,90)(81,82,83,84,85)(71,123,24,65,95)(72,124,25,61,91)(74,121,22,63,93)(75,122,23,64,94)(11,55,104,113,33),
#(70,80,60,50,100)(91,92,93,94,95)(72,83,64,55,105)(73,84,65,51,101)(75,81,62,53,103)(71,82,63,54,104)(15,45,114,123,23),
#(70,90,50,40,110)(101,102,103,104,105)(73,93,54,45,115)(74,94,55,41,111)(71,91,52,43,113)(72,92,53,44,114)(14,35,124,83,63),
#(70,100,40,30,120)(111,112,113,114,115)(74,103,44,35,125)(75,104,45,31,121)(72,101,42,33,123)(73,102,43,34,124)(13,25,84,93,53),
#(70,110,30,20,80)(121,122,123,124,125)(75,113,34,25,85)(71,114,35,21,81)(73,111,32,23,83)(74,112,33,24,84)(12,65,94,103,43)
);

### Typo in code

Ops, I found something wrong in this post already. I'll fix it here when I am certain.