emilgoldsmith/elm-speedcubing/3.0.0

NOTE: the latest version is 14.1.0

PLL

Types and helper functions to work with the Permutate Last Layer (PLL) algorithm set, the last step of the CFOP method. See https://www.speedsolving.com/wiki/index.php/PLL for further information

Definition And Constructors

type PLL
= H
| Ua
| Ub
| Z
| Aa
| Ab
| E
| F
| Ga
| Gb
| Gc
| Gd
| Ja
| Jb
| Na
| Nb
| Ra
| Rb
| T
| V
| Y

All the cases are represented here. Use the value constructors here or @all to specify a given case in your code, and pass these to any of the helper functions

all : Nonempty PLL

A non-empty list of all the PLLs. Can for example be used for randomly selecting a pll

import List.Nonempty


-- All the PLLs are there!
List.Nonempty.length all --> 21


-- We could for example select a random PLL case
-- via this
List.Nonempty.sample all

Helpers

getLetters : PLL -> String

Generates a string of the identifying letters of the case.

This could be used either for serialization purposes, or for building a string to display the user in some instances.

-- Format is always first letter capitalized and
-- the second one lower case if applicable
getLetters Ua --> "Ua"


getLetters H --> "H"

Collections

type alias Algorithms =
{ h : Algorithm
, ua : Algorithm
, ub : Algorithm
, z : Algorithm
, aa : Algorithm
, ab : Algorithm
, e : Algorithm
, f : Algorithm
, ga : Algorithm
, gb : Algorithm
, gc : Algorithm
, gd : Algorithm
, ja : Algorithm
, jb : Algorithm
, na : Algorithm
, nb : Algorithm
, ra : Algorithm
, rb : Algorithm
, t : Algorithm
, v : Algorithm
, y : Algorithm
}

A collection of algorithms that solves the respective case

getAlgorithm : Algorithms -> PLL -> Algorithm

Get the algorithm for the PLL case from an algorithm collection. This helps avoid any typos or need to write your own case statements in order to get the algorithm for a case passed to a function

getAlgorithm referenceAlgorithms Y
--> referenceAlgorithms.y
referenceAlgorithms : Algorithms

Plls verified to be correct so they can be used to verify user selected plls or for displaying a pll case somewhere on the site.

They have been chosen to be the optimally lowest move count in HTM just for a small performance boost.

The example tests below are just meant for an easier to read version of all the algorithms that are verified to be correct. They are also tested via elm-verify-examples so the string versions are correct equivalents to the code below.

import Algorithm


-- Edges Only


Algorithm.fromString "R2 U2 R U2 R2 U2 R2 U2 R U2 R2"
--> Ok referenceAlgorithms.h


Algorithm.fromString "F2 U' (L R') F2 (L' R) U' F2"
--> Ok referenceAlgorithms.ua


Algorithm.fromString "F2 U (R' L) F2 (R L') U F2"
--> Ok referenceAlgorithms.ub


Algorithm.fromString "R B' R' B F R' F B' R' B R F2"
--> Ok referenceAlgorithms.z


-- Corners Only


Algorithm.fromString "R' F R' B2 R F' R' B2 R2"
--> Ok referenceAlgorithms.aa


Algorithm.fromString "R B' R F2 R' B R F2 R2"
--> Ok referenceAlgorithms.ab


Algorithm.fromString "D R' D2 F' D L D' F D2 R D' F' L' F"
--> Ok referenceAlgorithms.e


-- Corners And Edges


Algorithm.fromString "L F R' F' L' F' D2 B' L' B D2 F' R F2"
--> Ok referenceAlgorithms.f


Algorithm.fromString "F2' D (R' U R' U' R) D' F2 L' U L"
--> Ok referenceAlgorithms.ga


Algorithm.fromString "R' U' R B2 D (L' U L U' L) D' B2"
--> Ok referenceAlgorithms.gb


Algorithm.fromString "R2' D' F U' F U F' D R2 B U' B'"
--> Ok referenceAlgorithms.gc


Algorithm.fromString "R U R' F2 D' (L U' L' U L') D F2"
--> Ok referenceAlgorithms.gd


Algorithm.fromString "B2 R' U' R B2 L' D L' D' L2"
--> Ok referenceAlgorithms.ja


Algorithm.fromString "B2 (L U L') B2 (R D' R D) R2"
--> Ok referenceAlgorithms.jb


Algorithm.fromString "L U' R U2 L' U R' L U' R U2 L' U R'"
--> Ok referenceAlgorithms.na


Algorithm.fromString "R' U L' U2 R U' L R' U L' U2 R U' L"
--> Ok referenceAlgorithms.nb


Algorithm.fromString "F2 R' F' U' F' U F R F' U2 F U2 F'"
--> Ok referenceAlgorithms.ra


Algorithm.fromString "R2 F R U R U' R' F' R U2 R' U2 R"
--> Ok referenceAlgorithms.rb


Algorithm.fromString "F2 D R2 U' R2 F2 D' L2 U L2"
--> Ok referenceAlgorithms.t


Algorithm.fromString "R' U R' U' B' R' B2 U' B' U B' R B R"
--> Ok referenceAlgorithms.v


Algorithm.fromString "F2 D R2 U R2 D' R' U' R F2 R' U R"
--> Ok referenceAlgorithms.y