-
Notifications
You must be signed in to change notification settings - Fork 1
/
solution.worksheet.sc
65 lines (44 loc) · 1.62 KB
/
solution.worksheet.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import twistygroups.cube.algs._
import perms._
////////////////////////////////////////////////////////////////
// An example scramble
////////////////////////////////////////////////////////////////
val scramble = R.D3.F2.U3.R2.U.B2.D3.F2.D.L2.F2.L2.B.U.F2.U3.B.D.R
println(scramble.state)
println(scramble.state.cp.pretty)
////////////////////////////////////////////////////////////////
// Goal: Generate commutators for all these triples
////////////////////////////////////////////////////////////////
val allCycles = for {
i <- 3 to 8
j <- 2 until i
k <- 1 until j
p <- Array(Perm(k,j,i), Perm(k,i,j))
} yield p
allCycles.size
val simpleComm = Comm(Conj(R2 * U, R2), D2).conjBy(U)
simpleComm.turns.mkString(" ")
(Conj(ID, simpleComm)).state.cp
val moreComms = for {
r2 <- List(R2, L2)
u <- List(U, U3)
d <- List(D, D2, D3)
topBotFlip <- List(ID, B2, L2, F2, R2)
topBotAlign <- List(ID, U, U2, U3, D, D2, D3)
} yield Comm(Conj(r2 * u, r2), d).conjBy(topBotFlip * topBotAlign)
assert(moreComms.forall(_.state.cp.image.sizeIs == 3))
moreComms.size
moreComms.distinctBy(_.state.cp).size
moreComms.map(_.state.cp.pretty) foreach println
allCycles.diff(moreComms.map(_.state.cp)).foreach(println)
val solutionCycles = scramble.state.cp.inverse.asThreeCycles.get.reverse
println(scramble.state.cp.pretty)
println(solutionCycles.map(_.pretty).mkString)
val steps: List[Alg] = solutionCycles.map{ cycle =>
moreComms.filter(cycle == _.state.cp.cycles.head).minBy(_.moves)
}
steps.foreach(println)
println(scramble.prettyTurns)
println(steps(0).prettyTurns)
println(steps(1).prettyTurns)
println(steps(2).prettyTurns)