Surface of the 3x3x3 cube as a graphFind the Chromatic NumberEdge Elimination NumberUndirect a GraphIs My Graph Planar?Strongly Connected ComponentsFind a dual graphFind a set of maximal matching edgesCalculate TreewidthDetermine if a Graph is ToroidalConstruct a line graph / conjugate graph
Secure offsite backup, even in the case of hacker root access
Sharing one invocation list between multiple events on the same object in C#
How do I write "Show, Don't Tell" as an Asperger?
How to supress loops in a digraph?
What do we gain with higher order logics?
PC video game involving floating islands doing aerial combat
When writing an error prompt, should we end the sentence with a exclamation mark or a dot?
Should I "tell" my exposition or give it through dialogue?
In this example, which path would a monster affected by the Dissonant Whispers spell take?
Word for a small burst of laughter that can't be held back
Payment instructions from HomeAway look fishy to me
Can you `= delete` a templated function on a second declaration?
Finding x,y coordinates where y is largest
Adding two lambda-functions in C++
What risks are there when you clear your cookies instead of logging off?
How hard would it be to convert a glider into an powered electric aircraft?
What's the correct term describing the action of sending a brand-new ship out into its first seafaring trip?
Avoiding cliches when writing gods
How to skip replacing first occurrence of a character in each line?
Bent spoke design wheels — feasible?
From system of coupled ODEs to separable ODE
Aligning object in a commutative diagram
Is it legal in the UK for politicians to lie to the public for political gain?
Whats the next step after commercial fusion reactors?
Surface of the 3x3x3 cube as a graph
Find the Chromatic NumberEdge Elimination NumberUndirect a GraphIs My Graph Planar?Strongly Connected ComponentsFind a dual graphFind a set of maximal matching edgesCalculate TreewidthDetermine if a Graph is ToroidalConstruct a line graph / conjugate graph
$begingroup$
Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side.
Rules
- You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a graph in an algorithm. (A visual graph readable by a human is generally not a reasonable format in an algorithm in most cases.)
- You may make either every vertex adjacent to itself, or none adjacent to itself.
- You may either include both directions for each edge (count one or two times for self-loops), or output exactly one time for each edge, but not mix the ways.
- You may renumber the vertices, skip some numbers, or even use non-number labels for the vertices in any way you want. You should also post the numbering if it isn't obvious, so others could check your answer in easier ways.
- This is code-golf. Shortest code in bytes wins.
Example output
This is the numbering of vertices used in the example:
0 1 2
3 4 5
6 7 8
9 10 11 18 19 20 27 28 29 36 37 38
12 13 14 21 22 23 30 31 32 39 40 41
15 16 17 24 25 26 33 34 35 42 43 44
45 46 47
48 49 50
51 52 53
Output as an adjacency list (vertex number before each list is optional):
0 [1 3 9 38]
1 [2 4 0 37]
2 [29 5 1 36]
3 [4 6 10 0]
4 [5 7 3 1]
5 [28 8 4 2]
6 [7 18 11 3]
7 [8 19 6 4]
8 [27 20 7 5]
9 [10 12 38 0]
10 [11 13 9 3]
11 [18 14 10 6]
12 [13 15 41 9]
13 [14 16 12 10]
14 [21 17 13 11]
15 [16 51 44 12]
16 [17 48 15 13]
17 [24 45 16 14]
18 [19 21 11 6]
19 [20 22 18 7]
20 [27 23 19 8]
21 [22 24 14 18]
22 [23 25 21 19]
23 [30 26 22 20]
24 [25 45 17 21]
25 [26 46 24 22]
26 [33 47 25 23]
27 [28 30 20 8]
28 [29 31 27 5]
29 [36 32 28 2]
30 [31 33 23 27]
31 [32 34 30 28]
32 [39 35 31 29]
33 [34 47 26 30]
34 [35 50 33 31]
35 [42 53 34 32]
36 [37 39 29 2]
37 [38 40 36 1]
38 [9 41 37 0]
39 [40 42 32 36]
40 [41 43 39 37]
41 [12 44 40 38]
42 [43 53 35 39]
43 [44 52 42 40]
44 [15 51 43 41]
45 [46 48 17 24]
46 [47 49 45 25]
47 [33 50 46 26]
48 [49 51 16 45]
49 [50 52 48 46]
50 [34 53 49 47]
51 [52 44 15 48]
52 [53 43 51 49]
53 [35 42 52 50]
code-golf kolmogorov-complexity graph-theory rubiks-cube
$endgroup$
add a comment |
$begingroup$
Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side.
Rules
- You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a graph in an algorithm. (A visual graph readable by a human is generally not a reasonable format in an algorithm in most cases.)
- You may make either every vertex adjacent to itself, or none adjacent to itself.
- You may either include both directions for each edge (count one or two times for self-loops), or output exactly one time for each edge, but not mix the ways.
- You may renumber the vertices, skip some numbers, or even use non-number labels for the vertices in any way you want. You should also post the numbering if it isn't obvious, so others could check your answer in easier ways.
- This is code-golf. Shortest code in bytes wins.
Example output
This is the numbering of vertices used in the example:
0 1 2
3 4 5
6 7 8
9 10 11 18 19 20 27 28 29 36 37 38
12 13 14 21 22 23 30 31 32 39 40 41
15 16 17 24 25 26 33 34 35 42 43 44
45 46 47
48 49 50
51 52 53
Output as an adjacency list (vertex number before each list is optional):
0 [1 3 9 38]
1 [2 4 0 37]
2 [29 5 1 36]
3 [4 6 10 0]
4 [5 7 3 1]
5 [28 8 4 2]
6 [7 18 11 3]
7 [8 19 6 4]
8 [27 20 7 5]
9 [10 12 38 0]
10 [11 13 9 3]
11 [18 14 10 6]
12 [13 15 41 9]
13 [14 16 12 10]
14 [21 17 13 11]
15 [16 51 44 12]
16 [17 48 15 13]
17 [24 45 16 14]
18 [19 21 11 6]
19 [20 22 18 7]
20 [27 23 19 8]
21 [22 24 14 18]
22 [23 25 21 19]
23 [30 26 22 20]
24 [25 45 17 21]
25 [26 46 24 22]
26 [33 47 25 23]
27 [28 30 20 8]
28 [29 31 27 5]
29 [36 32 28 2]
30 [31 33 23 27]
31 [32 34 30 28]
32 [39 35 31 29]
33 [34 47 26 30]
34 [35 50 33 31]
35 [42 53 34 32]
36 [37 39 29 2]
37 [38 40 36 1]
38 [9 41 37 0]
39 [40 42 32 36]
40 [41 43 39 37]
41 [12 44 40 38]
42 [43 53 35 39]
43 [44 52 42 40]
44 [15 51 43 41]
45 [46 48 17 24]
46 [47 49 45 25]
47 [33 50 46 26]
48 [49 51 16 45]
49 [50 52 48 46]
50 [34 53 49 47]
51 [52 44 15 48]
52 [53 43 51 49]
53 [35 42 52 50]
code-golf kolmogorov-complexity graph-theory rubiks-cube
$endgroup$
add a comment |
$begingroup$
Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side.
Rules
- You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a graph in an algorithm. (A visual graph readable by a human is generally not a reasonable format in an algorithm in most cases.)
- You may make either every vertex adjacent to itself, or none adjacent to itself.
- You may either include both directions for each edge (count one or two times for self-loops), or output exactly one time for each edge, but not mix the ways.
- You may renumber the vertices, skip some numbers, or even use non-number labels for the vertices in any way you want. You should also post the numbering if it isn't obvious, so others could check your answer in easier ways.
- This is code-golf. Shortest code in bytes wins.
Example output
This is the numbering of vertices used in the example:
0 1 2
3 4 5
6 7 8
9 10 11 18 19 20 27 28 29 36 37 38
12 13 14 21 22 23 30 31 32 39 40 41
15 16 17 24 25 26 33 34 35 42 43 44
45 46 47
48 49 50
51 52 53
Output as an adjacency list (vertex number before each list is optional):
0 [1 3 9 38]
1 [2 4 0 37]
2 [29 5 1 36]
3 [4 6 10 0]
4 [5 7 3 1]
5 [28 8 4 2]
6 [7 18 11 3]
7 [8 19 6 4]
8 [27 20 7 5]
9 [10 12 38 0]
10 [11 13 9 3]
11 [18 14 10 6]
12 [13 15 41 9]
13 [14 16 12 10]
14 [21 17 13 11]
15 [16 51 44 12]
16 [17 48 15 13]
17 [24 45 16 14]
18 [19 21 11 6]
19 [20 22 18 7]
20 [27 23 19 8]
21 [22 24 14 18]
22 [23 25 21 19]
23 [30 26 22 20]
24 [25 45 17 21]
25 [26 46 24 22]
26 [33 47 25 23]
27 [28 30 20 8]
28 [29 31 27 5]
29 [36 32 28 2]
30 [31 33 23 27]
31 [32 34 30 28]
32 [39 35 31 29]
33 [34 47 26 30]
34 [35 50 33 31]
35 [42 53 34 32]
36 [37 39 29 2]
37 [38 40 36 1]
38 [9 41 37 0]
39 [40 42 32 36]
40 [41 43 39 37]
41 [12 44 40 38]
42 [43 53 35 39]
43 [44 52 42 40]
44 [15 51 43 41]
45 [46 48 17 24]
46 [47 49 45 25]
47 [33 50 46 26]
48 [49 51 16 45]
49 [50 52 48 46]
50 [34 53 49 47]
51 [52 44 15 48]
52 [53 43 51 49]
53 [35 42 52 50]
code-golf kolmogorov-complexity graph-theory rubiks-cube
$endgroup$
Your task is to generate a graph with 54 vertices, each corresponds to a facet on a Rubik's cube. There is an edge between two vertices iff the corresponding facets share a side.
Rules
- You may choose to output an adjacency list, adjacency matrix, edge list, or any reasonable format to represent a graph in an algorithm. (A visual graph readable by a human is generally not a reasonable format in an algorithm in most cases.)
- You may make either every vertex adjacent to itself, or none adjacent to itself.
- You may either include both directions for each edge (count one or two times for self-loops), or output exactly one time for each edge, but not mix the ways.
- You may renumber the vertices, skip some numbers, or even use non-number labels for the vertices in any way you want. You should also post the numbering if it isn't obvious, so others could check your answer in easier ways.
- This is code-golf. Shortest code in bytes wins.
Example output
This is the numbering of vertices used in the example:
0 1 2
3 4 5
6 7 8
9 10 11 18 19 20 27 28 29 36 37 38
12 13 14 21 22 23 30 31 32 39 40 41
15 16 17 24 25 26 33 34 35 42 43 44
45 46 47
48 49 50
51 52 53
Output as an adjacency list (vertex number before each list is optional):
0 [1 3 9 38]
1 [2 4 0 37]
2 [29 5 1 36]
3 [4 6 10 0]
4 [5 7 3 1]
5 [28 8 4 2]
6 [7 18 11 3]
7 [8 19 6 4]
8 [27 20 7 5]
9 [10 12 38 0]
10 [11 13 9 3]
11 [18 14 10 6]
12 [13 15 41 9]
13 [14 16 12 10]
14 [21 17 13 11]
15 [16 51 44 12]
16 [17 48 15 13]
17 [24 45 16 14]
18 [19 21 11 6]
19 [20 22 18 7]
20 [27 23 19 8]
21 [22 24 14 18]
22 [23 25 21 19]
23 [30 26 22 20]
24 [25 45 17 21]
25 [26 46 24 22]
26 [33 47 25 23]
27 [28 30 20 8]
28 [29 31 27 5]
29 [36 32 28 2]
30 [31 33 23 27]
31 [32 34 30 28]
32 [39 35 31 29]
33 [34 47 26 30]
34 [35 50 33 31]
35 [42 53 34 32]
36 [37 39 29 2]
37 [38 40 36 1]
38 [9 41 37 0]
39 [40 42 32 36]
40 [41 43 39 37]
41 [12 44 40 38]
42 [43 53 35 39]
43 [44 52 42 40]
44 [15 51 43 41]
45 [46 48 17 24]
46 [47 49 45 25]
47 [33 50 46 26]
48 [49 51 16 45]
49 [50 52 48 46]
50 [34 53 49 47]
51 [52 44 15 48]
52 [53 43 51 49]
53 [35 42 52 50]
code-golf kolmogorov-complexity graph-theory rubiks-cube
code-golf kolmogorov-complexity graph-theory rubiks-cube
edited May 20 at 16:27
jimmy23013
asked May 19 at 20:25
jimmy23013jimmy23013
30.1k561132
30.1k561132
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
$begingroup$
APL (Dyalog Classic), 34 30 bytes
-4 thanks to jimmy23013
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
Try it online!
outputs an adjacency matrix with each vertex adjacent to itself
⍳3 3
generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)
○
multiply all by π
7 ¯1∘.,
prepend 7 or -1 in all possible ways
(⍳3)∘.⌽
rotate coord triples by 0 1 2 steps in all possible ways
+/¨|∘.-⍨,
compute manhattan distance between each pair
4≥
it must be no greater than 4 for neighbouring facets
$endgroup$
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
add a comment |
$begingroup$
Ruby, 79 bytes
54.timesi
Try it online!
Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.
0 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
$endgroup$
add a comment |
$begingroup$
Python 2.7, 145
def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]
Try it online!
Defines an adjacency matrix x
as a list of lists of boolean values. Facets count as being adjacent to themselves.
p(n)
computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).
$endgroup$
add a comment |
$begingroup$
Charcoal, 48 bytes
F⁷F⁷F⁷⊞υ⟦ικλ⟧≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υIEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
Try it online! Link is to verbose version of code. Explanation:
F⁷F⁷F⁷⊞υ⟦ικλ⟧
Generate all sets of 3-dimensional coordinates in the range [0..6]
for each dimension.
≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υ
Keep only those coordinates that are centres of 2x2
squares on one of the faces x=0
, y=0
, z=0
, x=6
, y=6
, z=6
.
IEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
For each coordinate, print the indices of those coordinates whose taxicab distance is 2.
The vertices are numbered as follows:
33 34 35
21 22 23
9 10 11
36 24 12 0 1 2 13 25 37 47 46 45
38 26 14 3 4 5 15 27 39 50 49 48
40 28 16 6 7 8 17 29 41 53 52 51
18 19 20
30 31 32
42 43 44
$endgroup$
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
add a comment |
$begingroup$
Wolfram Language 190 bytes
The following returns all of the graph edges in terms of the actual coordinates (assuming each mini-cube is 2 units at the edge and the Rubik's cube has its bottom left vertex at the origin).
t=Table;h[a_,b_,c_]:=t[x,y,z,a,1,5,2,b,1,5,2,c,0,6,6];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[h[x,z,y],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5,6,5,6,5,5,5,6,6,5,5,5,6,1,3,6,1,5,6,1,5,5,0,5,6,1,5,6,3,5,6,1,6,5,1,5,6,3,3,6,3,5,6,3,5,6,1,5,6,3,5,6,5,5,6,3,6,5,3,5,6,5,3,6,5,5,6,5,5,5,6,5,6,5,5,6,3,5,6,5,6,5,5,6,1,1,5,0,1,6,1,1,5,1,0,6,1,1,6,1,3,6,1,1,6,3,1,6,1,3,5,0,3,6,1,3,6,1,1,6,1,3,6,1,5,6,1,3,6,3,3,6,1,5,5,0,5,6,1,5,5,1,6,6,1,5,6,1,3,6,1,5,6,3,5,6,3,1,5,3,0,6,3,1,6,1,1,6,3,1,6,3,3,6,3,1,6,5,1,6,3,3,6,1,3,6,3,3,6,3,1,6,3,3,6,3,5,6,3,3,6,5,3,6,3,5,5,3,6,6,3,5,6,1,5,6,3,5,6,3,3,6,3,5,6,5,5,6,5,1,5,5,0,6,5,1,5,6,1,6,5,1,6,3,1,6,5,1,6,5,3,6,5,3,5,6,3,6,5,3,6,3,3,6,5,3,6,5,1,6,5,3,6,5,5,6,5,5,5,5,6,6,5,5,5,6,5,6,5,5,6,3,5,6,5,5,6,5,3
The work of generating the points on each external facet is done by the function, h
.
It has to be called 3 times to generate the points at x=0, x=6; y=0, y=6; and z=0,z=6.
Each facet point that is a Manhattan distance of 2 units from another will be connected to the respective point.
We can display the graph edges visually by the following; a
is the list of graph edges that are represented below as arrows.
Graphics3D[Arrowheads[.02],Arrow/@a,Boxed->False,Axes-> True]
The following shows the Rubik's cube, the points on the external facets, and 8 graph edges.
Red dots are located on facets at y = 0 and y = 6; blue and gray dots are on facets at x = 6 and x = 0, respectively; black dots are on facets at z=6 and z=0.
$endgroup$
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
add a comment |
$begingroup$
Rust - 278 bytes
fn main()let mut v=vec![];for x in vec![-2,0,2]for y in vec![-2,0,2]for z in vec![-2,2]v.push([-1,z,x,y]);v.push([0,x,y,z]);v.push([1,x,z,y]);for r in 0..54print!("n ",r);for s in 0..54n
Try on play.rust-lang.org
This is big, but the smallest code for a compiled language (so far). It creates an adjacency list. Its very similar to cardboard_box 's python answer but I wanted to see if Quaternions could work.
Step 1: Construct 54 Quaternions, each representing a single facet.
Step 2: for each Quaternion, list all other Quaternions with Quadrance (aka squared distance, aka squared norm of the difference) <= 4.
Quaternions are built like so: The imaginary vectors i j k are points on the shell of a grid, from -2,-2,-2 to 2,2,2, step 2. The real part w is always -1, 0, or 1, so that facets on opposite sides of the cube have the same real part, but adjacent sides have different real parts. The real part allows distinguishing different 'sides' of the cube through calculation.
Quaternion numbering (pseudo isometric 3d view of a cube):
->i ^j k
-2,+2,+2 +0,+2,+2 +2,+2,+2
-2,+0,+2 +0,+0,+2 +2,+0,+2
-2,-2,+2 +0,-2,+2 +2,-2,+2
w=0
-2,+2,+2 -2 +2 +2 +0 +2 +2 +2 +2 +2 +2,+2,+2
-2,+0,+2 +2,+0,+2
-2,-2,+2 -2 -2 +2 +0 -2 +2 +2 -2 +2 +2,-2,+2
-2,+2,+0 -2 +2 +0 +0 +2 +0 +2 +2 +0 +2,+2,+0
-2,+0,+0 +2,+0,+0
-2,-2,+0 -2 -2 +0 +0 -2 +0 +2 -2 +0 +2,-2,+0
-2,+2,-2 -2 +2 -2 +0 +2 -2 +2 +2 -2 +2,+2,-2
-2,+0,-2 w=1 +2,+0,-2
-2,-2,-2 -2 -2 -2 +0 -2 -2 +2 -2 -2 +2,-2,-2
w=-1 w=1 w=-1
-2,+2,-2 +0,+2,-2 +2,+2,-2
-2,+0,-2 +0,+0,-2 +2,+0,-2
-2,-2,-2 +0,-2,-2 +2,-2,-2
w=0
Indexed numbering (unfolded cube):
16 34 52
10 28 46
4 22 40
48 30 12 14 32 50 15 33 51
42 24 6 8 26 44 9 27 45
36 18 0 2 20 38 3 21 39
1 19 37
7 25 43
13 31 49
5 23 41
11 29 47
17 35 53
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6, Browser), 153 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||alert([i,j]),j++)[d,e,f]=F(j)
Try it online!
This is modified to reduce 5 bytes by making same points adjacent, i.e. $||mathbfA-B||leq1$.
JavaScript (ES6, Browser), 158 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||i-j&&alert([i,j]),j++)[d,e,f]=F(j)
Try it online! (simulates alert
with console.log
)
Maps the center of all 54 facets to the 3-d space and calculates whether $0<||mathbfA-B||leq1$ for every pair of points. Outputs all directed edges as pairs of numbers [a, b]
. The vertex map is
47 50 53
46 49 52
45 48 51
20 23 26 11 14 17 35 32 29 8 5 2
19 22 25 10 13 16 34 31 28 7 4 1
18 21 24 9 12 15 33 30 27 6 3 0
36 39 42
37 40 43
38 41 44
$endgroup$
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185807%2fsurface-of-the-3x3x3-cube-as-a-graph%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
APL (Dyalog Classic), 34 30 bytes
-4 thanks to jimmy23013
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
Try it online!
outputs an adjacency matrix with each vertex adjacent to itself
⍳3 3
generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)
○
multiply all by π
7 ¯1∘.,
prepend 7 or -1 in all possible ways
(⍳3)∘.⌽
rotate coord triples by 0 1 2 steps in all possible ways
+/¨|∘.-⍨,
compute manhattan distance between each pair
4≥
it must be no greater than 4 for neighbouring facets
$endgroup$
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
add a comment |
$begingroup$
APL (Dyalog Classic), 34 30 bytes
-4 thanks to jimmy23013
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
Try it online!
outputs an adjacency matrix with each vertex adjacent to itself
⍳3 3
generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)
○
multiply all by π
7 ¯1∘.,
prepend 7 or -1 in all possible ways
(⍳3)∘.⌽
rotate coord triples by 0 1 2 steps in all possible ways
+/¨|∘.-⍨,
compute manhattan distance between each pair
4≥
it must be no greater than 4 for neighbouring facets
$endgroup$
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
add a comment |
$begingroup$
APL (Dyalog Classic), 34 30 bytes
-4 thanks to jimmy23013
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
Try it online!
outputs an adjacency matrix with each vertex adjacent to itself
⍳3 3
generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)
○
multiply all by π
7 ¯1∘.,
prepend 7 or -1 in all possible ways
(⍳3)∘.⌽
rotate coord triples by 0 1 2 steps in all possible ways
+/¨|∘.-⍨,
compute manhattan distance between each pair
4≥
it must be no greater than 4 for neighbouring facets
$endgroup$
APL (Dyalog Classic), 34 30 bytes
-4 thanks to jimmy23013
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
Try it online!
outputs an adjacency matrix with each vertex adjacent to itself
⍳3 3
generate an array of (0 0)(0 1)(0 2)(1 0)(1 1)(1 2)(2 0)(2 1)(2 2)
○
multiply all by π
7 ¯1∘.,
prepend 7 or -1 in all possible ways
(⍳3)∘.⌽
rotate coord triples by 0 1 2 steps in all possible ways
+/¨|∘.-⍨,
compute manhattan distance between each pair
4≥
it must be no greater than 4 for neighbouring facets
edited May 19 at 23:51
answered May 19 at 21:32
ngnngn
7,60112661
7,60112661
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
add a comment |
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3
$endgroup$
– jimmy23013
May 19 at 23:41
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
@jimmy23013 using π is very nice :) thank you!
$endgroup$
– ngn
May 19 at 23:48
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
$begingroup$
54x54 matrix... thats impressive
$endgroup$
– don bright
May 27 at 20:29
add a comment |
$begingroup$
Ruby, 79 bytes
54.timesi
Try it online!
Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.
0 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
$endgroup$
add a comment |
$begingroup$
Ruby, 79 bytes
54.timesi
Try it online!
Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.
0 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
$endgroup$
add a comment |
$begingroup$
Ruby, 79 bytes
54.timesi
Try it online!
Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.
0 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
$endgroup$
Ruby, 79 bytes
54.timesi
Try it online!
Prints a representation of a unidirectional graph, as a list of the vertices to the right of and below each vertex as shown in the map below.
0 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
edited May 20 at 4:32
answered May 20 at 4:25
Level River StLevel River St
20.6k32683
20.6k32683
add a comment |
add a comment |
$begingroup$
Python 2.7, 145
def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]
Try it online!
Defines an adjacency matrix x
as a list of lists of boolean values. Facets count as being adjacent to themselves.
p(n)
computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).
$endgroup$
add a comment |
$begingroup$
Python 2.7, 145
def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]
Try it online!
Defines an adjacency matrix x
as a list of lists of boolean values. Facets count as being adjacent to themselves.
p(n)
computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).
$endgroup$
add a comment |
$begingroup$
Python 2.7, 145
def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]
Try it online!
Defines an adjacency matrix x
as a list of lists of boolean values. Facets count as being adjacent to themselves.
p(n)
computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).
$endgroup$
Python 2.7, 145
def p(n):l=(3-n%2*6,n/6%3*2-2,n/18*2-2);k=n/2%3;return l[k:]+l[:k]
r=range(54)
x=[[sum((x-y)**2for x,y in zip(p(i),p(j)))<5for i in r]for j in r]
Try it online!
Defines an adjacency matrix x
as a list of lists of boolean values. Facets count as being adjacent to themselves.
p(n)
computes the coordinates of the center of the nth facet of a 3x3x3 cube whose facets are 2 units across. Adjacency is determined by testing if 2 facets have a square distance under 5 (adjacent facets have square distance at most 4, non-adjacent facets have square distance at least 6).
answered May 19 at 23:18
cardboard_boxcardboard_box
4,1901431
4,1901431
add a comment |
add a comment |
$begingroup$
Charcoal, 48 bytes
F⁷F⁷F⁷⊞υ⟦ικλ⟧≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υIEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
Try it online! Link is to verbose version of code. Explanation:
F⁷F⁷F⁷⊞υ⟦ικλ⟧
Generate all sets of 3-dimensional coordinates in the range [0..6]
for each dimension.
≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υ
Keep only those coordinates that are centres of 2x2
squares on one of the faces x=0
, y=0
, z=0
, x=6
, y=6
, z=6
.
IEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
For each coordinate, print the indices of those coordinates whose taxicab distance is 2.
The vertices are numbered as follows:
33 34 35
21 22 23
9 10 11
36 24 12 0 1 2 13 25 37 47 46 45
38 26 14 3 4 5 15 27 39 50 49 48
40 28 16 6 7 8 17 29 41 53 52 51
18 19 20
30 31 32
42 43 44
$endgroup$
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
add a comment |
$begingroup$
Charcoal, 48 bytes
F⁷F⁷F⁷⊞υ⟦ικλ⟧≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υIEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
Try it online! Link is to verbose version of code. Explanation:
F⁷F⁷F⁷⊞υ⟦ικλ⟧
Generate all sets of 3-dimensional coordinates in the range [0..6]
for each dimension.
≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υ
Keep only those coordinates that are centres of 2x2
squares on one of the faces x=0
, y=0
, z=0
, x=6
, y=6
, z=6
.
IEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
For each coordinate, print the indices of those coordinates whose taxicab distance is 2.
The vertices are numbered as follows:
33 34 35
21 22 23
9 10 11
36 24 12 0 1 2 13 25 37 47 46 45
38 26 14 3 4 5 15 27 39 50 49 48
40 28 16 6 7 8 17 29 41 53 52 51
18 19 20
30 31 32
42 43 44
$endgroup$
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
add a comment |
$begingroup$
Charcoal, 48 bytes
F⁷F⁷F⁷⊞υ⟦ικλ⟧≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υIEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
Try it online! Link is to verbose version of code. Explanation:
F⁷F⁷F⁷⊞υ⟦ικλ⟧
Generate all sets of 3-dimensional coordinates in the range [0..6]
for each dimension.
≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υ
Keep only those coordinates that are centres of 2x2
squares on one of the faces x=0
, y=0
, z=0
, x=6
, y=6
, z=6
.
IEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
For each coordinate, print the indices of those coordinates whose taxicab distance is 2.
The vertices are numbered as follows:
33 34 35
21 22 23
9 10 11
36 24 12 0 1 2 13 25 37 47 46 45
38 26 14 3 4 5 15 27 39 50 49 48
40 28 16 6 7 8 17 29 41 53 52 51
18 19 20
30 31 32
42 43 44
$endgroup$
Charcoal, 48 bytes
F⁷F⁷F⁷⊞υ⟦ικλ⟧≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υIEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
Try it online! Link is to verbose version of code. Explanation:
F⁷F⁷F⁷⊞υ⟦ικλ⟧
Generate all sets of 3-dimensional coordinates in the range [0..6]
for each dimension.
≔Φυ⁼Φ﹪ι⁶¬﹪λ²⟦⁰⟧υ
Keep only those coordinates that are centres of 2x2
squares on one of the faces x=0
, y=0
, z=0
, x=6
, y=6
, z=6
.
IEυΦLυ⁼²ΣE§υλ↔⁻ν§ιξ
For each coordinate, print the indices of those coordinates whose taxicab distance is 2.
The vertices are numbered as follows:
33 34 35
21 22 23
9 10 11
36 24 12 0 1 2 13 25 37 47 46 45
38 26 14 3 4 5 15 27 39 50 49 48
40 28 16 6 7 8 17 29 41 53 52 51
18 19 20
30 31 32
42 43 44
answered May 19 at 23:45
NeilNeil
84.6k845183
84.6k845183
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
add a comment |
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
is there any documentation for charcoal on the web ?
$endgroup$
– don bright
May 27 at 20:32
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
$begingroup$
@donbright Follow the GitHub link in the answer title and click Wiki.
$endgroup$
– Neil
May 27 at 20:42
add a comment |
$begingroup$
Wolfram Language 190 bytes
The following returns all of the graph edges in terms of the actual coordinates (assuming each mini-cube is 2 units at the edge and the Rubik's cube has its bottom left vertex at the origin).
t=Table;h[a_,b_,c_]:=t[x,y,z,a,1,5,2,b,1,5,2,c,0,6,6];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[h[x,z,y],h[y,z,x],h[x,y,z],3],2],x_,x_],x_/;ManhattanDistance@@x==2]],4]
(* output *)
0,1,1,0,1,3,0,1,1,0,3,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,3,0,1,1,0,1,3,0,1,5,0,1,3,0,3,3,0,1,3,1,0,3,0,1,5,0,1,3,0,1,5,0,3,5,0,1,5,1,0,5,0,1,5,1,1,6,0,3,1,0,1,1,0,3,1,0,3,3,0,3,1,0,5,1,0,3,1,1,3,0,0,3,3,0,1,3,0,3,3,0,3,1,0,3,3,0,3,5,0,3,3,0,5,3,0,3,5,0,1,5,0,3,5,0,3,3,0,3,5,0,5,5,0,3,5,1,3,6,0,5,1,0,3,1,0,5,1,0,5,3,0,5,1,1,5,0,0,5,1,1,6,1,0,5,3,0,3,3,0,5,3,0,5,1,0,5,3,0,5,5,0,5,3,1,6,3,0,5,5,0,3,5,0,5,5,0,5,3,0,5,5,1,5,6,0,5,5,1,6,5,1,0,1,0,1,1,1,0,1,1,0,3,1,0,1,1,1,0,1,0,1,3,0,1,1,0,3,0,1,3,1,0,3,1,0,1,1,0,3,1,0,5,1,0,3,3,0,3,1,0,5,0,1,5,1,0,5,1,0,3,1,0,5,1,1,6,1,0,5,3,0,5,1,1,0,0,1,1,1,1,0,1,0,1,1,1,0,1,3,0,1,1,0,3,1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,0,3,5,0,1,5,0,3,5,0,5,5,0,3,6,1,3,5,0,5,3,0,5,5,0,5,5,0,3,5,0,5,5,1,6,5,0,5,6,1,5,5,1,0,3,1,0,5,1,0,5,0,1,5,1,0,5,3,0,5,1,0,6,1,1,5,1,6,3,1,6,5,1,6,5,0,5,5,1,6,5,3,6,5,1,6,6,1,5,5,3,0,3,3,0,5,3,0,5,1,0,5,3,0,5,5,0,5,3,0,6,3,1,5,3,6,3,3,6,5,3,6,5,1,6,5,3,6,5,5,6,5,3,6,6,3,5,5,5,0,3,5,0,5,5,0,5,3,0,5,5,0,5,6,1,5,5,0,6,5,1,5,5,6,3,5,6,5,5,6,5,3,6,5,5,6,5,6,5,5,5,6,6,5,5,5,6,1,3,6,1,5,6,1,5,5,0,5,6,1,5,6,3,5,6,1,6,5,1,5,6,3,3,6,3,5,6,3,5,6,1,5,6,3,5,6,5,5,6,3,6,5,3,5,6,5,3,6,5,5,6,5,5,5,6,5,6,5,5,6,3,5,6,5,6,5,5,6,1,1,5,0,1,6,1,1,5,1,0,6,1,1,6,1,3,6,1,1,6,3,1,6,1,3,5,0,3,6,1,3,6,1,1,6,1,3,6,1,5,6,1,3,6,3,3,6,1,5,5,0,5,6,1,5,5,1,6,6,1,5,6,1,3,6,1,5,6,3,5,6,3,1,5,3,0,6,3,1,6,1,1,6,3,1,6,3,3,6,3,1,6,5,1,6,3,3,6,1,3,6,3,3,6,3,1,6,3,3,6,3,5,6,3,3,6,5,3,6,3,5,5,3,6,6,3,5,6,1,5,6,3,5,6,3,3,6,3,5,6,5,5,6,5,1,5,5,0,6,5,1,5,6,1,6,5,1,6,3,1,6,5,1,6,5,3,6,5,3,5,6,3,6,5,3,6,3,3,6,5,3,6,5,1,6,5,3,6,5,5,6,5,5,5,5,6,6,5,5,5,6,5,6,5,5,6,3,5,6,5,5,6,5,3
The work of generating the points on each external facet is done by the function, h
.
It has to be called 3 times to generate the points at x=0, x=6; y=0, y=6; and z=0,z=6.
Each facet point that is a Manhattan distance of 2 units from another will be connected to the respective point.
We can display the graph edges visually by the following; a
is the list of graph edges that are represented below as arrows.
Graphics3D[Arrowheads[.02],Arrow/@a,Boxed->False,Axes-> True]
The following shows the Rubik's cube, the points on the external facets, and 8 graph edges.
Red dots are located on facets at y = 0 and y = 6; blue and gray dots are on facets at x = 6 and x = 0, respectively; black dots are on facets at z=6 and z=0.
$endgroup$
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
add a comment |
$begingroup$
Wolfram Language 190 bytes
The following returns all of the graph edges in terms of the actual coordinates (assuming each mini-cube is 2 units at the edge and the Rubik's cube has its bottom left vertex at the origin).
t=Table;h[a_,b_,c_]:=t[x,y,z,a,1,5,2,b,1,5,2,c,0,6,6];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[h[x,z,y],h[y,z,x],h[x,y,z],3],2],x_,x_],x_/;ManhattanDistance@@x==2]],4]
(* output *)
0,1,1,0,1,3,0,1,1,0,3,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,3,0,1,1,0,1,3,0,1,5,0,1,3,0,3,3,0,1,3,1,0,3,0,1,5,0,1,3,0,1,5,0,3,5,0,1,5,1,0,5,0,1,5,1,1,6,0,3,1,0,1,1,0,3,1,0,3,3,0,3,1,0,5,1,0,3,1,1,3,0,0,3,3,0,1,3,0,3,3,0,3,1,0,3,3,0,3,5,0,3,3,0,5,3,0,3,5,0,1,5,0,3,5,0,3,3,0,3,5,0,5,5,0,3,5,1,3,6,0,5,1,0,3,1,0,5,1,0,5,3,0,5,1,1,5,0,0,5,1,1,6,1,0,5,3,0,3,3,0,5,3,0,5,1,0,5,3,0,5,5,0,5,3,1,6,3,0,5,5,0,3,5,0,5,5,0,5,3,0,5,5,1,5,6,0,5,5,1,6,5,1,0,1,0,1,1,1,0,1,1,0,3,1,0,1,1,1,0,1,0,1,3,0,1,1,0,3,0,1,3,1,0,3,1,0,1,1,0,3,1,0,5,1,0,3,3,0,3,1,0,5,0,1,5,1,0,5,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of generating the points on each external facet is done by the function, h
.
It has to be called 3 times to generate the points at x=0, x=6; y=0, y=6; and z=0,z=6.
Each facet point that is a Manhattan distance of 2 units from another will be connected to the respective point.
We can display the graph edges visually by the following; a
is the list of graph edges that are represented below as arrows.
Graphics3D[Arrowheads[.02],Arrow/@a,Boxed->False,Axes-> True]
The following shows the Rubik's cube, the points on the external facets, and 8 graph edges.
Red dots are located on facets at y = 0 and y = 6; blue and gray dots are on facets at x = 6 and x = 0, respectively; black dots are on facets at z=6 and z=0.
$endgroup$
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
add a comment |
$begingroup$
Wolfram Language 190 bytes
The following returns all of the graph edges in terms of the actual coordinates (assuming each mini-cube is 2 units at the edge and the Rubik's cube has its bottom left vertex at the origin).
t=Table;h[a_,b_,c_]:=t[x,y,z,a,1,5,2,b,1,5,2,c,0,6,6];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[h[x,z,y],h[y,z,x],h[x,y,z],3],2],x_,x_],x_/;ManhattanDistance@@x==2]],4]
(* output *)
0,1,1,0,1,3,0,1,1,0,3,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,3,0,1,1,0,1,3,0,1,5,0,1,3,0,3,3,0,1,3,1,0,3,0,1,5,0,1,3,0,1,5,0,3,5,0,1,5,1,0,5,0,1,5,1,1,6,0,3,1,0,1,1,0,3,1,0,3,3,0,3,1,0,5,1,0,3,1,1,3,0,0,3,3,0,1,3,0,3,3,0,3,1,0,3,3,0,3,5,0,3,3,0,5,3,0,3,5,0,1,5,0,3,5,0,3,3,0,3,5,0,5,5,0,3,5,1,3,6,0,5,1,0,3,1,0,5,1,0,5,3,0,5,1,1,5,0,0,5,1,1,6,1,0,5,3,0,3,3,0,5,3,0,5,1,0,5,3,0,5,5,0,5,3,1,6,3,0,5,5,0,3,5,0,5,5,0,5,3,0,5,5,1,5,6,0,5,5,1,6,5,1,0,1,0,1,1,1,0,1,1,0,3,1,0,1,1,1,0,1,0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,6,5,3,6,5,1,6,5,3,6,5,5,6,5,5,5,5,6,6,5,5,5,6,5,6,5,5,6,3,5,6,5,5,6,5,3
The work of generating the points on each external facet is done by the function, h
.
It has to be called 3 times to generate the points at x=0, x=6; y=0, y=6; and z=0,z=6.
Each facet point that is a Manhattan distance of 2 units from another will be connected to the respective point.
We can display the graph edges visually by the following; a
is the list of graph edges that are represented below as arrows.
Graphics3D[Arrowheads[.02],Arrow/@a,Boxed->False,Axes-> True]
The following shows the Rubik's cube, the points on the external facets, and 8 graph edges.
Red dots are located on facets at y = 0 and y = 6; blue and gray dots are on facets at x = 6 and x = 0, respectively; black dots are on facets at z=6 and z=0.
$endgroup$
Wolfram Language 190 bytes
The following returns all of the graph edges in terms of the actual coordinates (assuming each mini-cube is 2 units at the edge and the Rubik's cube has its bottom left vertex at the origin).
t=Table;h[a_,b_,c_]:=t[x,y,z,a,1,5,2,b,1,5,2,c,0,6,6];Partition[Sort[a=Cases[DeleteCases[Tuples[Flatten[h[x,z,y],h[y,z,x],h[x,y,z],3],2],x_,x_],x_/;ManhattanDistance@@x==2]],4]
(* output *)
0,1,1,0,1,3,0,1,1,0,3,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,3,0,1,1,0,1,3,0,1,5,0,1,3,0,3,3,0,1,3,1,0,3,0,1,5,0,1,3,0,1,5,0,3,5,0,1,5,1,0,5,0,1,5,1,1,6,0,3,1,0,1,1,0,3,1,0,3,3,0,3,1,0,5,1,0,3,1,1,3,0,0,3,3,0,1,3,0,3,3,0,3,1,0,3,3,0,3,5,0,3,3,0,5,3,0,3,5,0,1,5,0,3,5,0,3,3,0,3,5,0,5,5,0,3,5,1,3,6,0,5,1,0,3,1,0,5,1,0,5,3,0,5,1,1,5,0,0,5,1,1,6,1,0,5,3,0,3,3,0,5,3,0,5,1,0,5,3,0,5,5,0,5,3,1,6,3,0,5,5,0,3,5,0,5,5,0,5,3,0,5,5,1,5,6,0,5,5,1,6,5,1,0,1,0,1,1,1,0,1,1,0,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5,6,3,6,5,3,6,3,3,6,5,3,6,5,1,6,5,3,6,5,5,6,5,5,5,5,6,6,5,5,5,6,5,6,5,5,6,3,5,6,5,5,6,5,3
The work of generating the points on each external facet is done by the function, h
.
It has to be called 3 times to generate the points at x=0, x=6; y=0, y=6; and z=0,z=6.
Each facet point that is a Manhattan distance of 2 units from another will be connected to the respective point.
We can display the graph edges visually by the following; a
is the list of graph edges that are represented below as arrows.
Graphics3D[Arrowheads[.02],Arrow/@a,Boxed->False,Axes-> True]
The following shows the Rubik's cube, the points on the external facets, and 8 graph edges.
Red dots are located on facets at y = 0 and y = 6; blue and gray dots are on facets at x = 6 and x = 0, respectively; black dots are on facets at z=6 and z=0.
edited May 26 at 0:55
answered May 25 at 22:21
DavidCDavidC
24.2k246102
24.2k246102
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
add a comment |
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
$begingroup$
nice pictures, arrowheads is really cool
$endgroup$
– don bright
May 26 at 0:53
add a comment |
$begingroup$
Rust - 278 bytes
fn main()let mut v=vec![];for x in vec![-2,0,2]for y in vec![-2,0,2]for z in vec![-2,2]v.push([-1,z,x,y]);v.push([0,x,y,z]);v.push([1,x,z,y]);for r in 0..54print!("n ",r);for s in 0..54n
Try on play.rust-lang.org
This is big, but the smallest code for a compiled language (so far). It creates an adjacency list. Its very similar to cardboard_box 's python answer but I wanted to see if Quaternions could work.
Step 1: Construct 54 Quaternions, each representing a single facet.
Step 2: for each Quaternion, list all other Quaternions with Quadrance (aka squared distance, aka squared norm of the difference) <= 4.
Quaternions are built like so: The imaginary vectors i j k are points on the shell of a grid, from -2,-2,-2 to 2,2,2, step 2. The real part w is always -1, 0, or 1, so that facets on opposite sides of the cube have the same real part, but adjacent sides have different real parts. The real part allows distinguishing different 'sides' of the cube through calculation.
Quaternion numbering (pseudo isometric 3d view of a cube):
->i ^j k
-2,+2,+2 +0,+2,+2 +2,+2,+2
-2,+0,+2 +0,+0,+2 +2,+0,+2
-2,-2,+2 +0,-2,+2 +2,-2,+2
w=0
-2,+2,+2 -2 +2 +2 +0 +2 +2 +2 +2 +2 +2,+2,+2
-2,+0,+2 +2,+0,+2
-2,-2,+2 -2 -2 +2 +0 -2 +2 +2 -2 +2 +2,-2,+2
-2,+2,+0 -2 +2 +0 +0 +2 +0 +2 +2 +0 +2,+2,+0
-2,+0,+0 +2,+0,+0
-2,-2,+0 -2 -2 +0 +0 -2 +0 +2 -2 +0 +2,-2,+0
-2,+2,-2 -2 +2 -2 +0 +2 -2 +2 +2 -2 +2,+2,-2
-2,+0,-2 w=1 +2,+0,-2
-2,-2,-2 -2 -2 -2 +0 -2 -2 +2 -2 -2 +2,-2,-2
w=-1 w=1 w=-1
-2,+2,-2 +0,+2,-2 +2,+2,-2
-2,+0,-2 +0,+0,-2 +2,+0,-2
-2,-2,-2 +0,-2,-2 +2,-2,-2
w=0
Indexed numbering (unfolded cube):
16 34 52
10 28 46
4 22 40
48 30 12 14 32 50 15 33 51
42 24 6 8 26 44 9 27 45
36 18 0 2 20 38 3 21 39
1 19 37
7 25 43
13 31 49
5 23 41
11 29 47
17 35 53
$endgroup$
add a comment |
$begingroup$
Rust - 278 bytes
fn main()let mut v=vec![];for x in vec![-2,0,2]for y in vec![-2,0,2]for z in vec![-2,2]v.push([-1,z,x,y]);v.push([0,x,y,z]);v.push([1,x,z,y]);for r in 0..54print!("n ",r);for s in 0..54n
Try on play.rust-lang.org
This is big, but the smallest code for a compiled language (so far). It creates an adjacency list. Its very similar to cardboard_box 's python answer but I wanted to see if Quaternions could work.
Step 1: Construct 54 Quaternions, each representing a single facet.
Step 2: for each Quaternion, list all other Quaternions with Quadrance (aka squared distance, aka squared norm of the difference) <= 4.
Quaternions are built like so: The imaginary vectors i j k are points on the shell of a grid, from -2,-2,-2 to 2,2,2, step 2. The real part w is always -1, 0, or 1, so that facets on opposite sides of the cube have the same real part, but adjacent sides have different real parts. The real part allows distinguishing different 'sides' of the cube through calculation.
Quaternion numbering (pseudo isometric 3d view of a cube):
->i ^j k
-2,+2,+2 +0,+2,+2 +2,+2,+2
-2,+0,+2 +0,+0,+2 +2,+0,+2
-2,-2,+2 +0,-2,+2 +2,-2,+2
w=0
-2,+2,+2 -2 +2 +2 +0 +2 +2 +2 +2 +2 +2,+2,+2
-2,+0,+2 +2,+0,+2
-2,-2,+2 -2 -2 +2 +0 -2 +2 +2 -2 +2 +2,-2,+2
-2,+2,+0 -2 +2 +0 +0 +2 +0 +2 +2 +0 +2,+2,+0
-2,+0,+0 +2,+0,+0
-2,-2,+0 -2 -2 +0 +0 -2 +0 +2 -2 +0 +2,-2,+0
-2,+2,-2 -2 +2 -2 +0 +2 -2 +2 +2 -2 +2,+2,-2
-2,+0,-2 w=1 +2,+0,-2
-2,-2,-2 -2 -2 -2 +0 -2 -2 +2 -2 -2 +2,-2,-2
w=-1 w=1 w=-1
-2,+2,-2 +0,+2,-2 +2,+2,-2
-2,+0,-2 +0,+0,-2 +2,+0,-2
-2,-2,-2 +0,-2,-2 +2,-2,-2
w=0
Indexed numbering (unfolded cube):
16 34 52
10 28 46
4 22 40
48 30 12 14 32 50 15 33 51
42 24 6 8 26 44 9 27 45
36 18 0 2 20 38 3 21 39
1 19 37
7 25 43
13 31 49
5 23 41
11 29 47
17 35 53
$endgroup$
add a comment |
$begingroup$
Rust - 278 bytes
fn main()let mut v=vec![];for x in vec![-2,0,2]for y in vec![-2,0,2]for z in vec![-2,2]v.push([-1,z,x,y]);v.push([0,x,y,z]);v.push([1,x,z,y]);for r in 0..54print!("n ",r);for s in 0..54n
Try on play.rust-lang.org
This is big, but the smallest code for a compiled language (so far). It creates an adjacency list. Its very similar to cardboard_box 's python answer but I wanted to see if Quaternions could work.
Step 1: Construct 54 Quaternions, each representing a single facet.
Step 2: for each Quaternion, list all other Quaternions with Quadrance (aka squared distance, aka squared norm of the difference) <= 4.
Quaternions are built like so: The imaginary vectors i j k are points on the shell of a grid, from -2,-2,-2 to 2,2,2, step 2. The real part w is always -1, 0, or 1, so that facets on opposite sides of the cube have the same real part, but adjacent sides have different real parts. The real part allows distinguishing different 'sides' of the cube through calculation.
Quaternion numbering (pseudo isometric 3d view of a cube):
->i ^j k
-2,+2,+2 +0,+2,+2 +2,+2,+2
-2,+0,+2 +0,+0,+2 +2,+0,+2
-2,-2,+2 +0,-2,+2 +2,-2,+2
w=0
-2,+2,+2 -2 +2 +2 +0 +2 +2 +2 +2 +2 +2,+2,+2
-2,+0,+2 +2,+0,+2
-2,-2,+2 -2 -2 +2 +0 -2 +2 +2 -2 +2 +2,-2,+2
-2,+2,+0 -2 +2 +0 +0 +2 +0 +2 +2 +0 +2,+2,+0
-2,+0,+0 +2,+0,+0
-2,-2,+0 -2 -2 +0 +0 -2 +0 +2 -2 +0 +2,-2,+0
-2,+2,-2 -2 +2 -2 +0 +2 -2 +2 +2 -2 +2,+2,-2
-2,+0,-2 w=1 +2,+0,-2
-2,-2,-2 -2 -2 -2 +0 -2 -2 +2 -2 -2 +2,-2,-2
w=-1 w=1 w=-1
-2,+2,-2 +0,+2,-2 +2,+2,-2
-2,+0,-2 +0,+0,-2 +2,+0,-2
-2,-2,-2 +0,-2,-2 +2,-2,-2
w=0
Indexed numbering (unfolded cube):
16 34 52
10 28 46
4 22 40
48 30 12 14 32 50 15 33 51
42 24 6 8 26 44 9 27 45
36 18 0 2 20 38 3 21 39
1 19 37
7 25 43
13 31 49
5 23 41
11 29 47
17 35 53
$endgroup$
Rust - 278 bytes
fn main()let mut v=vec![];for x in vec![-2,0,2]for y in vec![-2,0,2]for z in vec![-2,2]v.push([-1,z,x,y]);v.push([0,x,y,z]);v.push([1,x,z,y]);for r in 0..54print!("n ",r);for s in 0..54n
Try on play.rust-lang.org
This is big, but the smallest code for a compiled language (so far). It creates an adjacency list. Its very similar to cardboard_box 's python answer but I wanted to see if Quaternions could work.
Step 1: Construct 54 Quaternions, each representing a single facet.
Step 2: for each Quaternion, list all other Quaternions with Quadrance (aka squared distance, aka squared norm of the difference) <= 4.
Quaternions are built like so: The imaginary vectors i j k are points on the shell of a grid, from -2,-2,-2 to 2,2,2, step 2. The real part w is always -1, 0, or 1, so that facets on opposite sides of the cube have the same real part, but adjacent sides have different real parts. The real part allows distinguishing different 'sides' of the cube through calculation.
Quaternion numbering (pseudo isometric 3d view of a cube):
->i ^j k
-2,+2,+2 +0,+2,+2 +2,+2,+2
-2,+0,+2 +0,+0,+2 +2,+0,+2
-2,-2,+2 +0,-2,+2 +2,-2,+2
w=0
-2,+2,+2 -2 +2 +2 +0 +2 +2 +2 +2 +2 +2,+2,+2
-2,+0,+2 +2,+0,+2
-2,-2,+2 -2 -2 +2 +0 -2 +2 +2 -2 +2 +2,-2,+2
-2,+2,+0 -2 +2 +0 +0 +2 +0 +2 +2 +0 +2,+2,+0
-2,+0,+0 +2,+0,+0
-2,-2,+0 -2 -2 +0 +0 -2 +0 +2 -2 +0 +2,-2,+0
-2,+2,-2 -2 +2 -2 +0 +2 -2 +2 +2 -2 +2,+2,-2
-2,+0,-2 w=1 +2,+0,-2
-2,-2,-2 -2 -2 -2 +0 -2 -2 +2 -2 -2 +2,-2,-2
w=-1 w=1 w=-1
-2,+2,-2 +0,+2,-2 +2,+2,-2
-2,+0,-2 +0,+0,-2 +2,+0,-2
-2,-2,-2 +0,-2,-2 +2,-2,-2
w=0
Indexed numbering (unfolded cube):
16 34 52
10 28 46
4 22 40
48 30 12 14 32 50 15 33 51
42 24 6 8 26 44 9 27 45
36 18 0 2 20 38 3 21 39
1 19 37
7 25 43
13 31 49
5 23 41
11 29 47
17 35 53
edited May 25 at 20:32
answered May 25 at 20:21
don brightdon bright
919714
919714
add a comment |
add a comment |
$begingroup$
JavaScript (ES6, Browser), 153 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||alert([i,j]),j++)[d,e,f]=F(j)
Try it online!
This is modified to reduce 5 bytes by making same points adjacent, i.e. $||mathbfA-B||leq1$.
JavaScript (ES6, Browser), 158 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||i-j&&alert([i,j]),j++)[d,e,f]=F(j)
Try it online! (simulates alert
with console.log
)
Maps the center of all 54 facets to the 3-d space and calculates whether $0<||mathbfA-B||leq1$ for every pair of points. Outputs all directed edges as pairs of numbers [a, b]
. The vertex map is
47 50 53
46 49 52
45 48 51
20 23 26 11 14 17 35 32 29 8 5 2
19 22 25 10 13 16 34 31 28 7 4 1
18 21 24 9 12 15 33 30 27 6 3 0
36 39 42
37 40 43
38 41 44
$endgroup$
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
add a comment |
$begingroup$
JavaScript (ES6, Browser), 153 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||alert([i,j]),j++)[d,e,f]=F(j)
Try it online!
This is modified to reduce 5 bytes by making same points adjacent, i.e. $||mathbfA-B||leq1$.
JavaScript (ES6, Browser), 158 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||i-j&&alert([i,j]),j++)[d,e,f]=F(j)
Try it online! (simulates alert
with console.log
)
Maps the center of all 54 facets to the 3-d space and calculates whether $0<||mathbfA-B||leq1$ for every pair of points. Outputs all directed edges as pairs of numbers [a, b]
. The vertex map is
47 50 53
46 49 52
45 48 51
20 23 26 11 14 17 35 32 29 8 5 2
19 22 25 10 13 16 34 31 28 7 4 1
18 21 24 9 12 15 33 30 27 6 3 0
36 39 42
37 40 43
38 41 44
$endgroup$
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
add a comment |
$begingroup$
JavaScript (ES6, Browser), 153 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||alert([i,j]),j++)[d,e,f]=F(j)
Try it online!
This is modified to reduce 5 bytes by making same points adjacent, i.e. $||mathbfA-B||leq1$.
JavaScript (ES6, Browser), 158 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||i-j&&alert([i,j]),j++)[d,e,f]=F(j)
Try it online! (simulates alert
with console.log
)
Maps the center of all 54 facets to the 3-d space and calculates whether $0<||mathbfA-B||leq1$ for every pair of points. Outputs all directed edges as pairs of numbers [a, b]
. The vertex map is
47 50 53
46 49 52
45 48 51
20 23 26 11 14 17 35 32 29 8 5 2
19 22 25 10 13 16 34 31 28 7 4 1
18 21 24 9 12 15 33 30 27 6 3 0
36 39 42
37 40 43
38 41 44
$endgroup$
JavaScript (ES6, Browser), 153 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||alert([i,j]),j++)[d,e,f]=F(j)
Try it online!
This is modified to reduce 5 bytes by making same points adjacent, i.e. $||mathbfA-B||leq1$.
JavaScript (ES6, Browser), 158 bytes
for(F=n=>(A=[n%9/3|0,n%3]).splice(n/18,0,(n/9&1)*3-.5)&&A,i=0;i<54;i++)for([a,b,c]=F(i),j=0;j<54;Math.hypot(a-d,b-e,c-f)>1||i-j&&alert([i,j]),j++)[d,e,f]=F(j)
Try it online! (simulates alert
with console.log
)
Maps the center of all 54 facets to the 3-d space and calculates whether $0<||mathbfA-B||leq1$ for every pair of points. Outputs all directed edges as pairs of numbers [a, b]
. The vertex map is
47 50 53
46 49 52
45 48 51
20 23 26 11 14 17 35 32 29 8 5 2
19 22 25 10 13 16 34 31 28 7 4 1
18 21 24 9 12 15 33 30 27 6 3 0
36 39 42
37 40 43
38 41 44
edited May 27 at 11:33
answered May 27 at 1:24
Shieru AsakotoShieru Asakoto
2,995319
2,995319
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
add a comment |
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
$begingroup$
i didnt even know there was a Math.hypot
$endgroup$
– don bright
May 27 at 20:27
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185807%2fsurface-of-the-3x3x3-cube-as-a-graph%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown