Skip to main content
added 24 characters in body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112

Ruby, 55 bytes

20.times{|j|p ~0**j*(1.309-k=j/10),1.618**k*1i**j*=0.4} 

Try it online!

Golfed version using decimal approximations instead of exact formulas (I can't use fractions as Ruby would dointerpret using integer arithmetic.) Dimensions are now half the ones given in the wolfram page, instead of double, to avoid j/10*4. The polar vertices are now listed before the equatorial vertices, to enable the distance from the z axis to be calculated as 1.618**k (1 or 1.618)

I also deleted the [] to save 2 bytes, although this impacts readability of the output.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi] and scaled. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

Ruby, 55 bytes

20.times{|j|p ~0**j*(1.309-k=j/10),1.618**k*1i**j*=0.4} 

Try it online!

Golfed version using decimal approximations instead of exact formulas (I can't use fractions as Ruby would do integer arithmetic.) Dimensions are now half the ones given in the wolfram page, instead of double, to avoid j/10*4. The polar vertices are now listed before the equatorial vertices, to enable the distance from the z axis to be calculated as 1.618**k (1 or 1.618)

I also deleted the [] to save 2 bytes, although this impacts readability of the output.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

Ruby, 55 bytes

20.times{|j|p ~0**j*(1.309-k=j/10),1.618**k*1i**j*=0.4} 

Try it online!

Golfed version using decimal approximations instead of exact formulas (I can't use fractions as Ruby would interpret using integer arithmetic.) Dimensions are now half the ones given in the wolfram page, instead of double, to avoid j/10*4. The polar vertices are now listed before the equatorial vertices, to enable the distance from the z axis to be calculated as 1.618**k (1 or 1.618)

I also deleted the [] to save 2 bytes, although this impacts readability of the output.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi] and scaled. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

added 1127 characters in body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112

Ruby, 55 bytes

20.times{|j|p ~0**j*(1.309-k=j/10),1.618**k*1i**j*=0.4} 

Try it online!

Golfed version using decimal approximations instead of exact formulas (I can't use fractions as Ruby would do integer arithmetic.) Dimensions are now half the ones given in the wolfram page, instead of double, to avoid j/10*4. The polar vertices are now listed before the equatorial vertices, to enable the distance from the z axis to be calculated as 1.618**k (1 or 1.618)

I also deleted the [] to save 2 bytes, although this impacts readability of the output.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

Ruby, 55 bytes

20.times{|j|p ~0**j*(1.309-k=j/10),1.618**k*1i**j*=0.4} 

Try it online!

Golfed version using decimal approximations instead of exact formulas (I can't use fractions as Ruby would do integer arithmetic.) Dimensions are now half the ones given in the wolfram page, instead of double, to avoid j/10*4. The polar vertices are now listed before the equatorial vertices, to enable the distance from the z axis to be calculated as 1.618**k (1 or 1.618)

I also deleted the [] to save 2 bytes, although this impacts readability of the output.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

added 508 characters in body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112

Ruby, 8585 63 bytes

20.times{|j|p [~0**j*[0[~0**j*z=5**0.2628665-1+j/10*4,1.11532][r=(j*=0.4)[8/4]z,[-14].37638,-0max*1i**j*=0.850651][r]*1i**j]4]} 

Try it online!Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

The code can be shortened by rescaling (starting by removing the two - signs which are only there to flip the axis to match the orientation of the coordinates given in the question.) I will do this when I have time (it's 2am here.) Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

Ruby, 85 bytes

20.times{|j|p [~0**j*[0.262866,1.11532][r=(j*=0.4)/4],[-1.37638,-0.850651][r]*1i**j]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

The code can be shortened by rescaling (starting by removing the two - signs which are only there to flip the axis to match the orientation of the coordinates given in the question.) I will do this when I have time (it's 2am here.) Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia.

Ruby, 85 63 bytes

20.times{|j|p [~0**j*z=5**0.5-1+j/10*4,[8/z,4].max*1i**j*=0.4]} 

Try it online!

The coordinates given in the question are x,y,z with the dodecahedron's 5-fold rotational symmetry axis aligned with the z axis (It's actually a 10-fold axis for the rotate-and-flip operation.). This program outputs the same coordinates as the ones in the question, but in the format [z,x+yi]. First all the equatorial vertices are output, and then the polar vertices.

~0**j alternates the sign of the z coordinate as the x and y coordinates cycle through the 1/10th of a circle rotations. (-1**j would not work because unary minus has lower priority than raising to a power in Ruby.)

Exact coordinates in terms of the golden ratio are given at the wolfram page in formulas 1 and 2. The alternate coordinate system used in other answers is given a little below them on the same page, as well as in wikipedia. This code uses double the scale used in the Wolfram page, to avoid the division by 2 required to calculate the golden ratio. The footer in TIO link scales the coordinates given in the question and moves the z coordinate to the beginning for comparison. You still have to squint a bit because I've sorted the coordinates given in the question by z value, whereas the above code generates the vertices in an intercalated order with alternating sign of the z value.

deleted 1 character in body
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112
Loading
Source Link
Level River St
  • 28.8k
  • 4
  • 40
  • 112
Loading