Listing 10 --------------------- SUB Edges3 PrStr "Sort top edge cubes", 3: correct = 0 'first note centre colours of faces F, R, B & L fc=c(5,2,2): rc=c(4,2,2): bc=c(6,2,2): lc=c(3,2,2) 'find which cubes are in correct position IF c(1,2,1)=fc OR c(5,1,2)=fc THEN correct=1000 IF c(1,3,2)=rc OR c(4,3,2)=rc THEN correct=correct+100 IF c(1,2,3)=bc OR c(6,2,3)=bc THEN correct=correct+10 IF c(1,1,2)=lc OR c(3,2,1)=lc THEN correct=correct+1 IF correct = 0 THEN 'none of cubes in right place IF c(1,2,1) = rc OR c(5,1,2) = rc THEN 'if u/r at u/f RotCube 'rotate whole cube. note new centre colours fc =c(5,2,2):rc =c(4,2,2):bc =c(6,2,2): lc =c(3,2,2) END IF IF c(1,2,1) = bc OR c(5,1,2) = bc THEN 'if u/b at u/f PrStr "R2L2DR2L2U2R2L2DR2L2 ",5 'swap opposite pairs Rotpr 4, 2: Rotpr 3, 2: Rotpr 2, 1: Rotpr 4, 2 Rotpr 3, 2: Rotpr 1, 2: Rotpr 4, 2: Rotpr 3, 2 Rotpr 2, 1: Rotpr 4, 2: Rotpr 3, 2 END IF IF c(1,2,1) = lc OR c(5,1,2) = lc THEN 'if u/l at u/f PrStr "RBUB-1U-1R2F-1U-1FUR ",5 'swap adjacent pairs Rotpr 4, 1: Rotpr 6, 1: Rotpr 1, 1: Rotpr 6, 3 Rotpr 1, 3: Rotpr 4, 2: Rotpr 5, 3: Rotpr 1, 3 Rotpr 5, 1: Rotpr 1, 1: Rotpr 4, 1 END IF END IF SELECT CASE correct 'One cube only correct. Rotate 'whole cube to put it at u/r position CASE 1000: RotCube: RotCube: RotCube CASE 10: RotCube CASE 1: RotCube: RotCube END SELECT 'in effect, now correct = 100 bc = c(6,2,2): lc = c(3,2,2) 'centre colours of B & L IF c(1,2,1) = bc OR c(5,1,2) = bc THEN 'if u/b at u/f PrStr "L2U-1F-1BL2FB-1U-1L2 ",5 'circulate anticlock Rotpr 3,2: Rotpr 1,3: Rotpr 5,3: Rotpr 6,1: Rotpr 3,2 Rotpr 5, 1: Rotpr 6, 3: Rotpr 1, 3: Rotpr 3, 2 END IF IF c(1,2,1) = lc OR c(5,1,2) = lc THEN 'if u/l at u/f PrStr "ie. L2UF-1BL2FB-1UL2 ", 5 'circulate clockwise Rotpr 3,2: Rotpr 1,1: Rotpr 5,3: Rotpr 6,1: Rotpr 3,2 Rotpr 5, 1: Rotpr 6, 3: Rotpr 1, 1: Rotpr 3, 2 END IF PrStr blank, 3: PrStr blank, 4 PrStr blank, 5: PrStr blank, 6 END SUB End of Listing 10 ------------------------------- Listing 11 SUB Flips 'flips top edge cubes uc = c(1, 2, 2) 'colour of U centre DO UNTIL c(1,2,1) = uc AND c(1,1,2) = uc.. ... AND c(1,2,3) = uc AND c(1,3,2) = uc n = 0 'ie. until all top faces match uc DO UNTIL c(1, 2, 1) = c(5, 2, 2) OR n = 4 n = n + 1: RotCube 'until u/f needs flip LOOP 'if n reaches 4, all are correct 'cubes needing flip always occur in pairs IF n < 4 THEN 'u/f needs flip. Find other IF c(1, 3, 2) = c(4, 2, 2) THEN other = 4 'u/r needs flip PrStr "u/f & u/r need flip ", 2 ELSE IF c(1, 2, 3) = c(6, 2, 2) THEN other = 6 'u/b needs flip PrStr "u/f & u/b need flip ", 2 ELSE other = 3 'u/l needs flip PrStr "u/f & u/l need flip ", 2 END IF END IF PrStr "Flip pair top edges ", 4 PrStr "Firstly FUD-1L2U2D2R ", 5 Rotpr 5,1: Rotpr 1,1:Rotpr 2,3:Rotpr 3,2 Rotpr 1,2: Rotpr 2,2:Rotpr 4,1 PrStr "2nd of pair to u/r ", 5 IF other = 4 THEN Rotpr 1, 1 IF other = 6 THEN Rotpr 1, 2 IF other = 3 THEN Rotpr 1, 3 PrStr "Now R-1D2U2L2DU-1F-1", 5 Rotpr 4,3: Rotpr 2,2:Rotpr 1,2:Rotpr 3,2 Rotpr 2,1: Rotpr 1,3:Rotpr 5,3 IF other = 4 THEN Rotpr 1, 3 IF other = 6 THEN Rotpr 1, 2 IF other = 3 THEN Rotpr 1, 1 PrStr blank, 2 END IF LOOP PrStr blank, 3: PrStr blank, 4 PrStr blank, 5: PrStr blank, 6 END SUB End of Listing 11 ------------------------------------ Listing 12 SUB Twirls 'twirls top corner cubes uc = c(1, 2, 2) 'U centre colour DO 'outer loop i = 0: j = 0: k = 0: l = 0 IF c(5, 1, 3) = uc THEN i = 1 'u/f/r IF c(4, 3, 3) = uc THEN i = -1 IF c(4, 3, 1) = uc THEN j = 1 'u/r/b IF c(6, 1, 3) = uc THEN j = -1 IF c(6, 3, 3) = uc THEN k = 1 'u/b/l IF c(3, 3, 1) = uc THEN k = -1 IF c(3, 1, 1) = uc THEN l = 1 'u/l/f IF c(5, 1, 1) = uc THEN l = -1 sum = ABS(i) + ABS(j) + ABS(k) + ABS(l) SELECT CASE sum CASE 4, 2: DO UNTIL c(5, 1, 3) = uc 'until.. RotCube '..u/f/r needs clock twirl LOOP IF c(5, 1, 1) = uc THEN num = 3 'ie. u/l/f needs anticlock twirl IF c(3, 3, 1) = uc THEN num = 2 'ie. u/b/l needs anticlock twirl IF c(6, 1, 3) = uc THEN num = 1 'ie. u/r/b needs anticlock twirl CASE 3: num = 1 END SELECT LOCATE 2, 58: PRINT sum; num; IF sum > 0 THEN PrStr "Twirl two top corners ", 3 PrStr "First of pair (u/r) ", 4 PrStr "ie. R-1DRFDF-1 ", 5 Rotpr 4, 3: Rotpr 2, 1: Rotpr 4, 1 Rotpr 5, 1: Rotpr 2, 1: Rotpr 5, 3 PrStr "Move 2nd to u/r ", 4 PrStr blank, 5: Rotpr 1, num PrStr "2nd of pair (u/r) ", 4 PrStr "ie. FD-1F-1R-1D-1R ", 5 Rotpr 5, 1: Rotpr 2, 3: Rotpr 5, 3 Rotpr 4, 3: Rotpr 2, 3: Rotpr 4, 1 PrStr "Move 2nd to orig. pos.", 4 PrStr blank, 5: Rotpr 1, 4 - num END IF LOOP UNTIL sum = 0 PrStr blank, 2: PrStr blank, 3 PrStr blank, 4: PrStr blank, 5 PrStr blank, 6: END SUB End of Listing 12 ----------------------------------