Skip to main content
added 273 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 31 25 bytes

®X‚D3ãsãvy5t<;D>‚*¾š2Ý._« 

Uses \$\sqrt{3}\$ as the distance of each vector from the origin \$\{0,0\}\$. Will output the following 20 vertex-coordinates:

$$[\{-1,-1,-1\},\{-1,-1,1\},\{-1,1,-1\},\{-1,1,1\},\{1,-1,-1\},\{1,-1,1\},\{1,1,-1\},\{1,1,1\},\{0,-\phi,-\phi-1\},\{-\phi,-\phi-1,0\},\{-\phi-1,0,-\phi\},\{0,-\phi,\phi+1\},\{-\phi,\phi+1,0\},\{\phi+1,0,-\phi\},\{0,\phi,-\phi-1\},\{\phi,-\phi-1,0\},\{-\phi-1,0,\phi\},\{0,\phi,\phi+1\},\{\phi,\phi+1,0\},\{\phi+1,0,\phi\}]$$

Try it online.

Explanation:

®X‚ # Push pair [-1,1] D # Duplicate it 3ã # Get all possible triplets using the cartesian power of 3 s # Swap so the [-1,1] pair is at the top again ã # Also get all possible pairs using the cartesian power of 2 vy # Loop over each pair of [±1,±1]: 5t<; # Push the golden ratio: (sqrt(5)-1)/2 D # Duplicate it > # Increase the copy by 1 ‚ # Pair it together with the (sqrt(5)-1)/2 y * # Multiply the values in the pair to pair [±1,±1] at the same positions ¾š # Prepend a 0 to this pair 2Ý # Push list [0,1,2] ._ # Rotate the triplet that many times to the left « # Merge it to the original list of [-1,1]-triplets # (after which the list of 20 triplets is output implicitly as result) 

I started with a port of this SO C# answer, but noticed (for \$r=\sqrt{3}\$ at least):

  • \$±\frac{1}{\sqrt{3}}\times\phi\times\sqrt{3}\$ is simply \$±\phi\$
  • \$±\frac{\frac{1}{\sqrt{3}}}{\phi}\times\sqrt{3}\$ is simply \$±(\phi+1)\$

Try it online.

05AB1E, 31 25 bytes

®X‚D3ãsãvy5t<;D>‚*¾š2Ý._« 

Uses \$\sqrt{3}\$ as the distance of each vector from the origin \$\{0,0\}\$. Will output the following 20 vertex-coordinates:

$$[\{-1,-1,-1\},\{-1,-1,1\},\{-1,1,-1\},\{-1,1,1\},\{1,-1,-1\},\{1,-1,1\},\{1,1,-1\},\{1,1,1\},\{0,-\phi,-\phi-1\},\{-\phi,-\phi-1,0\},\{-\phi-1,0,-\phi\},\{0,-\phi,\phi+1\},\{-\phi,\phi+1,0\},\{\phi+1,0,-\phi\},\{0,\phi,-\phi-1\},\{\phi,-\phi-1,0\},\{-\phi-1,0,\phi\},\{0,\phi,\phi+1\},\{\phi,\phi+1,0\},\{\phi+1,0,\phi\}]$$

Try it online.

Explanation:

®X‚ # Push pair [-1,1] D # Duplicate it 3ã # Get all possible triplets using the cartesian power of 3 s # Swap so the [-1,1] pair is at the top again ã # Also get all possible pairs using the cartesian power of 2 vy # Loop over each pair of [±1,±1]: 5t<; # Push the golden ratio: (sqrt(5)-1)/2 D # Duplicate it > # Increase the copy by 1 ‚ # Pair it together with the (sqrt(5)-1)/2 y * # Multiply the values in the pair to pair [±1,±1] at the same positions ¾š # Prepend a 0 to this pair 2Ý # Push list [0,1,2] ._ # Rotate the triplet that many times to the left « # Merge it to the original list of [-1,1]-triplets # (after which the list of 20 triplets is output implicitly as result) 

05AB1E, 31 25 bytes

®X‚D3ãsãvy5t<;D>‚*¾š2Ý._« 

Uses \$\sqrt{3}\$ as the distance of each vector from the origin \$\{0,0\}\$. Will output the following 20 vertex-coordinates:

$$[\{-1,-1,-1\},\{-1,-1,1\},\{-1,1,-1\},\{-1,1,1\},\{1,-1,-1\},\{1,-1,1\},\{1,1,-1\},\{1,1,1\},\{0,-\phi,-\phi-1\},\{-\phi,-\phi-1,0\},\{-\phi-1,0,-\phi\},\{0,-\phi,\phi+1\},\{-\phi,\phi+1,0\},\{\phi+1,0,-\phi\},\{0,\phi,-\phi-1\},\{\phi,-\phi-1,0\},\{-\phi-1,0,\phi\},\{0,\phi,\phi+1\},\{\phi,\phi+1,0\},\{\phi+1,0,\phi\}]$$

Try it online.

Explanation:

®X‚ # Push pair [-1,1] D # Duplicate it 3ã # Get all possible triplets using the cartesian power of 3 s # Swap so the [-1,1] pair is at the top again ã # Also get all possible pairs using the cartesian power of 2 vy # Loop over each pair of [±1,±1]: 5t<; # Push the golden ratio: (sqrt(5)-1)/2 D # Duplicate it > # Increase the copy by 1 ‚ # Pair it together with the (sqrt(5)-1)/2 y * # Multiply the values in the pair to pair [±1,±1] at the same positions ¾š # Prepend a 0 to this pair 2Ý # Push list [0,1,2] ._ # Rotate the triplet that many times to the left « # Merge it to the original list of [-1,1]-triplets # (after which the list of 20 triplets is output implicitly as result) 

I started with a port of this SO C# answer, but noticed (for \$r=\sqrt{3}\$ at least):

  • \$±\frac{1}{\sqrt{3}}\times\phi\times\sqrt{3}\$ is simply \$±\phi\$
  • \$±\frac{\frac{1}{\sqrt{3}}}{\phi}\times\sqrt{3}\$ is simply \$±(\phi+1)\$

Try it online.

Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 31 25 bytes

®X‚D3ãsãvy5t<;D>‚*¾š2Ý._« 

Uses \$\sqrt{3}\$ as the distance of each vector from the origin \$\{0,0\}\$. Will output the following 20 vertex-coordinates:

$$[\{-1,-1,-1\},\{-1,-1,1\},\{-1,1,-1\},\{-1,1,1\},\{1,-1,-1\},\{1,-1,1\},\{1,1,-1\},\{1,1,1\},\{0,-\phi,-\phi-1\},\{-\phi,-\phi-1,0\},\{-\phi-1,0,-\phi\},\{0,-\phi,\phi+1\},\{-\phi,\phi+1,0\},\{\phi+1,0,-\phi\},\{0,\phi,-\phi-1\},\{\phi,-\phi-1,0\},\{-\phi-1,0,\phi\},\{0,\phi,\phi+1\},\{\phi,\phi+1,0\},\{\phi+1,0,\phi\}]$$

Try it online.

Explanation:

®X‚ # Push pair [-1,1] D # Duplicate it 3ã # Get all possible triplets using the cartesian power of 3 s # Swap so the [-1,1] pair is at the top again ã # Also get all possible pairs using the cartesian power of 2 vy # Loop over each pair of [±1,±1]: 5t<; # Push the golden ratio: (sqrt(5)-1)/2 D # Duplicate it > # Increase the copy by 1 ‚ # Pair it together with the (sqrt(5)-1)/2 y * # Multiply the values in the pair to pair [±1,±1] at the same positions ¾š # Prepend a 0 to this pair 2Ý # Push list [0,1,2] ._ # Rotate the triplet that many times to the left « # Merge it to the original list of [-1,1]-triplets # (after which the list of 20 triplets is output implicitly as result)