UP

Function setup_cube


Definition

    ∇ State←State setup_cube Clear;C;E;Old;New;Spaces;N;S1;N1;NewState
[1]  ⍝
[2]  ⍝⍝ set up a cube by entering the colors of its facets (in 2D view)
[3]  ⍝
[4]  →∆3D↓1+↑⎕LC ◊ 0 show_cube State
[5]  C←1 1 1 1 0 1 1 1 1 ◊ E←0 1 1 1 0 1 1 0 1 1 1 0 0
[6]  '' ◊ 'Please enter the colors for faces U, L, F, R, B, and D below.' ◊ ''
[7]  ' --Face U--   --Face L--   --Face F--   --Face R--   --Face B--   --Face D-'
[8]  Old←'' ◊ ⊣{ Old←Old, E\C/,(face ⍵) ⌷ State } ¨ ⍳6 ◊ Old←¯2↓Old
[9]  LOOP: →Clear/1+↑⎕LC ◊ ⍞←Old
[10] New←⍞ ◊ Spaces←+/∧\New=' ' ◊ Clear←0
[11] New←(New∈'YOBRGW')/New←(Spaces↑Old),Spaces↓New
[12] →(8=N←+/New='B')/1+↑⎕LC ◊ 'Error: need 8 blue (B) but got'   N ◊ →LOOP
[13] →(8=N←+/New='O')/1+↑⎕LC ◊ 'Error: need 8 orange (O) but got' N ◊ →LOOP
[14] →(8=N←+/New='Y')/1+↑⎕LC ◊ 'Error: need 8 yellow (Y) but got' N ◊ →LOOP
[15] →(8=N←+/New='R')/1+↑⎕LC ◊ 'Error: need 8 red (R) but got'    N ◊ →LOOP
[16] →(8=N←+/New='W')/1+↑⎕LC ◊ 'Error: need 8 white (W) but got'  N ◊ →LOOP
[17] →(8=N←+/New='G')/1+↑⎕LC ◊ 'Error: need 8 green (G) but got'  N ◊ →LOOP
[18] NewState←State ◊ ⊣{ (C/,(face ⍵) ⌷ NewState)←New[(⍳8)+8×⍵-1] } ¨ ⍳6
[19] S1←S1[⍋S1←{ ⍵[⍋⍵] }¨⊂[2]State] ◊ N1←N1[⍋N1←{ ⍵[⍋⍵] }¨⊂[2]NewState]
[20] →(S1≡¨N1)/CE   ⍝ OK: same cubes as before
[21] 'Error: cube(s)' ,(⍕(∼S1∈N1)/S1), 'missing. Please try again.' ◊ →LOOP
[22] CE: →(edge_parity NewState)↓C3
[23] 'Error: bad edge parity (cube cannot be solved). Please try again.' ◊ →LOOP
[24] C3: →(parity3 NewState)↓OK
[25] 'Error: bad corner 3-parity (cube cannot be solved). Please try again.' ◊ →LOOP
[26] OK: State←NewState
    ∇

Call Graph (defined functions called from function setup_cube)

Caller Graph (defined functions calling function setup_cube)