62--------64--------61--------63
           |58       |60       |57       |59
          46  54    48  56    45  53    47  55
           |42  50--  44--52----41--49----43--51
          30  38 |  32  40 |  29  37 |  31  39 |
           |26  34   | 28 36 |  25  33   |27  35
          14--22-|--16---24|--13--21-|--15  23 |
            10  18    12  20     9  17    11  19
               6 |       8 |       5 |       7 |
                 2-------- 4-------- 1-------- 3

m = [62,58,54,50,46,42,38,34,30,26,22,18,14,10,6,2,64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4,61,57,53,49,45,41,37,33,29,25,21,17,13,9,5,1,63,59,55,51,47,43,39,35,31,27,23,19,15,11,7,3]
___ Solution: 960 ___ [02:11:31] ___________________

Number of solutions: 960   Number of backtracks: 108410885
Elapsed time: 02:17:21               

 
// May 15 2016

// 108 rev 24 planar rev 4 maj diag rev

// Dwane Campbell gave a 1st check and thought there were 864 rectangles in the 4x4x4 cube that had this opposite diagonal equal sum property

// Harry White notes that not only do the 108 2x2 subsquares have to have this opposite diagonal equal sum property but also every row/col/pillar has to have equal sums for symmetrically opposite pairs.  With all these constraints there are 960 unique examples.  Walter Trump notes that if you have two sets that have the same number of elements in such a situation you are well on your way to providing the connection between the most-perfect magic cube and the reversible cube.
   
local C :< L = 130

pred MagicCube4x4x4(n::[0..63]->>L[1..64]) iff
    n = [
        n01,n02,n03,n04,n05,n06,n07,n08,
        n09,n10,n11,n12,n13,n14,n15,n16,
        n17,n18,n19,n20,n21,n22,n23,n24,
        n25,n26,n27,n28,n29,n30,n31,n32,
        n33,n34,n35,n36,n37,n38,n39,n40,
        n41,n42,n43,n44,n45,n46,n47,n48,
        n49,n50,n51,n52,n53,n54,n55,n56,
        n57,n58,n59,n60,n61,n62,n63,n64
        ] &


// Symmetry reduction

n32 < n15 &
n15 < n12 &
    

// 4x4x4 cube corners polarized and symmetrically redundant solutions removed.

n16 < n49 &
n16 < n04 &
n16 < n52 &
n16 < n01 &
n16 < n13 &
n16 < n64 &
n16 < n61 &


// 4 maj diag accross cube symm opposite pairs equal 
n01 + n64 = n22 + n43 &
n04 + n61 = n23 + n42 &
n13 + n52 = n26 + n39 &
n16 + n49 = n27 + n38 &



//  24 diag symmetrically opposite pairs on the diagonals of the 12 planes equal


// xy planes  4 total


n01 + n52 = n18 + n35 &
n04 + n49 = n19 + n34 &

n05 + n56 = n22 + n39 &
n08 + n53 = n23 + n38 &

n09 + n60 = n26 + n43 &
n12 + n57 = n27 + n42 &

n13 + n64 = n30 + n47 &
n16 + n61 = n31 + n46 &


// xz planes  4 total

n04 + n64 = n24 + n44 &
n16 + n52 = n28 + n40 &

n03 + n63 = n23 + n43 &
n15 + n51 = n27 + n39 &

n02 + n62 = n22 + n42 &
n14 + n50 = n26 + n38 &

n01 + n61 = n21 + n41 &
n13 + n49 = n25 + n37 &


// zy planes 4 total

n01 + n16 = n06 + n11 &
n04 + n13 = n07 + n10 &

n17 + n32 = n22 + n27 &
n20 + n29 = n23 + n26 &

n33 + n48 = n38 + n43 &
n36 + n45 = n39 + n42 &


n49 + n64 = n54 + n59 &
n52 + n61 = n55 + n58 &






// reversible criterai 108

     // 2x2 cell blocks on the x,y plane

n01 + n18 = n02 + n17 &
n17 + n34 = n18 + n33 &
n33 + n50 = n34 + n49 &
n02 + n19 = n03 + n18 &
n18 + n35 = n19 + n34 &
n34 + n51 = n35 + n50 &
n03 + n20 = n04 + n19 &
n19 + n36 = n20 + n35 &
n35 + n52 = n36 + n51 &
n05 + n22 = n06 + n21 &
n21 + n38 = n22 + n37 &
n37 + n54 = n38 + n53 &
n06 + n23 = n07 + n22 &
n22 + n39 = n23 + n38 &
n38 + n55 = n39 + n54 &
n07 + n24 = n08 + n23 &
n23 + n40 = n24 + n39 &
n39 + n56 = n40 + n55 &
n09 + n26 = n10 + n25 &
n25 + n42 = n26 + n41 &
n41 + n58 = n42 + n57 &
n10 + n27 = n11 + n26 &
n26 + n43 = n27 + n42 &
n42 + n59 = n43 + n58 &
n11 + n28 = n12 + n27 &
n27 + n44 = n28 + n43 & 
n43 + n60 = n44 + n59 & 
n13 + n30 = n14 + n29 &
n29 + n46 = n30 + n45 &
n45 + n62 = n46 + n61 & 
n14 + n31 = n15 + n30 &
n30 + n47 = n31 + n46 &
n46 + n63 = n47 + n62 &
n15 + n32 = n16 + n31 &
n31 + n48 = n32 + n47 &
n47 + n64 = n48 + n63 &







// 2x2 cell blocks on the x,z plane

n01 + n06 = n02 + n05 &
n17 + n22 = n18 + n21 &
n33 + n38 = n34 + n37 &
n49 + n54 = n50 + n53 &
n02 + n07 = n03 + n06 &
n18 + n23 = n19 + n22 &
n34 + n39 = n35 + n38 &
n50 + n55 = n51 + n54 &
n03 + n08 = n04 + n07 &
n19 + n24 = n20 + n23 &
n35 + n40 = n36 + n39 &
n51 + n56 = n52 + n55 &

n05 + n10 = n06 + n09 &
n21 + n26 = n22 + n25 &
n37 + n42 = n38 + n41 &
n53 + n58 = n54 + n57 &
n06 + n11 = n07 + n10 &
n22 + n27 = n23 + n26 &
n38 + n43 = n39 + n42 &
n54 + n59 = n55 + n58 &
n07 + n12 = n08 + n11 &
n23 + n28 = n24 + n27 &
n39 + n44 = n40 + n43 &
n55 + n60 = n56 + n59 &

n09 + n14 = n10 + n13 &
n25 + n30 = n26 + n29 &
n41 + n46 = n42 + n45 &
n57 + n62 = n58 + n61 &
n10 + n15 = n11 + n14 &
n26 + n31 = n27 + n30 &
n42 + n47 = n43 + n46 &
n58 + n63 = n59 + n62 &
n11 + n16 = n12 + n15 &
n27 + n32 = n28 + n31 &
n43 + n48 = n44 + n47 &
n59 + n64 = n60 + n63 &






   

// 2x2 cell blocks on the y,z plane

n01 + n21 = n05 + n17 &
n02 + n22 = n06 + n18 &
n03 + n23 = n07 + n19 &
n04 + n24 = n08 + n20 &
n17 + n37 = n21 + n33 &
n18 + n38 = n22 + n34 &
n19 + n39 = n23 + n35 &
n20 + n40 = n24 + n36 &
n33 + n53 = n37 + n49 &
n34 + n54 = n38 + n50 &
n35 + n55 = n39 + n51 &
n36 + n56 = n40 + n52 &
n05 + n25 = n09 + n21 &
n06 + n26 = n10 + n22 &
n07 + n27 = n11 + n23 &
n08 + n28 = n12 + n24 &
n21 + n41 = n25 + n37 &
n22 + n42 = n26 + n38 &
n23 + n43 = n27 + n39 &
n24 + n44 = n28 + n40 &
n37 + n57 = n41 + n53 &
n38 + n58 = n42 + n54 &
n39 + n59 = n43 + n55 &
n40 + n60 = n44 + n56 &
n09 + n29 = n13 + n25 &
n10 + n30 = n14 + n26 &
n11 + n31 = n15 + n27 &
n12 + n32 = n16 + n28 &
n25 + n45 = n29 + n41 &
n26 + n46 = n30 + n42 &
n27 + n47 = n31 + n43 &
n28 + n48 = n32 + n44 &
n41 + n61 = n45 + n57 &
n42 + n62 = n46 + n58 &
n43 + n63 = n47 + n59 &
n44 + n64 = n48 + n60 &








  

  n01 < C
  
  

   & PrettyPrint4x4x4(n,0) 


////////////////////////////////////////////////////////////////////////////////
//
// Some spaghetti code to print the resulting values as the 3D following pattern:
// (Note the array index is zero-based)
//
//      1--------17--------33--------49
//      | 2       |18       |34       |50
//      5   3    21  19    37  35    53  51
//      | 6   4--  22--20----38--36----54--52
//      9   7 |  25  23 |  41  39 |  57  55 |
//      |10   8   | 26 24 |  42  40   |58  56
//     13--11-|--29---27|--45--43-|--61  59 |
//       14  12    30   28   46  44    62  60
//         15 |      31 |      47 |      63 |
//           16--------32--------48--------64
//
////////////////////////////////////////////////////////////////////////////////

     local proc PrettyPrint4x4x4(n:<[0..]->L, row :< I) iff
    Print('\n\t') &
    if row = 0 then
        Digit(n(0)) & Print('--------') & Digit(n(16)) & Print('--------') & 
        Digit(n(32)) & Print('--------') & Digit(n(48)) & 
        PrettyPrint4x4x4(n,row+1)
    elsif row = 1 then
        Print(' |') & Digit(n(1)) & Print('       |') & Digit(n(17)) & 
        Print('       |') & Digit(n(33)) & Print('       |') & Digit(n(49)) & 
        PrettyPrint4x4x4(n,row+1)
    elsif row = 2 then 
        Digit(n(4)) & Print('  ') & Digit(n(2))& Print('    ') & Digit(n(20))& 
        Print('  ') & Digit(n(18)) & Print('    ')& Digit(n(36))& 
        Print('  ') & Digit(n(34)) & Print('    ') & Digit(n(52)) & Print('  ') &
        Digit(n(50)) &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 3 then
        Print(' |') & Digit(n(5))& Print('  ')& Digit(n(3)) & Print('--  ') & 
        Digit(n(21)) & Print('--') & Digit(n(19))  & Print('----') &
        Digit(n(37)) & Print('--') & Digit(n(35)) & Print('----') & Digit(n(53)) &
        Print('--') & Digit(n(51)) &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 4 then
        Digit(n(8)) & Print('  ') & Digit(n(6)) & Print(' |  ') & Digit(n(24)) & 
        Print('  ') & Digit(n(22))& Print(' |  ') & Digit(n(40)) & Print('  ') & 
        Digit(n(38)) & Print(' |  ') & Digit(n(56)) & Print('  ') & Digit(n(54)) & 
        Print(' |') &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 5 then 
        Print(' |') & Digit(n(9)) & Print('  ') & Digit(n(7)) & Print('   | ') & 
        Digit(n(25)) & Print(' ') & Digit(n(23)) & Print(' |  ') & Digit(n(41)) & 
        Print('  ') & Digit(n(39)) & Print('   |') & Digit(n(57)) & Print('  ') & 
        Digit(n(55)) &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 6 then
        Digit(n(12)) & Print('--') & Digit(n(10)) & Print('-|--') & Digit(n(28)) & 
        Print('---') & Digit(n(26))& Print('|--') & Digit(n(44))&
        Print('--') & Digit(n(42)) & Print('-|--') & Digit(n(60)) & Print('  ') & 
        Digit(n(58)) & Print(' |') &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 7 then
        Print('  ') & Digit(n(13)) & Print('  ') & Digit(n(11)) & Print('    ')& 
        Digit(n(29))& Print('  ') & Digit(n(27)) & Print('    ') & Digit(n(45)) & 
        Print('  ') & Digit(n(43)) & Print('    ') & Digit(n(61)) & Print('  ') & 
        Digit(n(59)) &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 8 then
        Print('    ') &  Digit(n(14)) & Print(' |      ') & Digit(n(30)) & 
        Print(' |      ') & Digit(n(46)) & Print(' |      ') & Digit(n(62))& 
        Print(' |') &
        PrettyPrint4x4x4(n,row+1)
    elsif row = 9 then
        Print('      ') & Digit(n(15)) & Print('--------') & Digit(n(31)) & 
        Print('--------') & Digit(n(47)) & Print('--------') & Digit(n(63)) &
        Print('\n')
    end
    
local proc Digit(d:<L) iff
    if d < 10 then
        Print(' ',d)
    else
        Print(d)
    end