Skip to main content
Became Hot Network Question
added 67 characters in body; edited tags
Source Link

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$, \$(0,2^n-1,0)\$, and \$(0,0,2^n-1)\$.)

Let \$s_2(n)\$ refer to the number of 1s in the binary expansion of \$n\$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon \$(x,y,z)\$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including \$n=10\$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

This is a code golf challenge, so shortest code (in bytes) wins.

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$, \$(0,2^n-1,0)\$, and \$(0,0,2^n-1)\$.)

Let \$s_2(n)\$ refer to the number of 1s in the binary expansion of \$n\$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon \$(x,y,z)\$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including \$n=10\$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$, \$(0,2^n-1,0)\$, and \$(0,0,2^n-1)\$.)

Let \$s_2(n)\$ refer to the number of 1s in the binary expansion of \$n\$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon \$(x,y,z)\$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including \$n=10\$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

This is a code golf challenge, so shortest code (in bytes) wins.

added 22 characters in body
Source Link

Write a program that, for any $n$\$n\$, generates a triangle made of hexagons as shown, $2^n$\$2^n\$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple $(x,y,z)$\$(x,y,z)\$ with $x+y+z=2^n-1$\$x+y+z=2^n-1\$. (The three corners will be $(2^n-1,0,0)$, $(0,2^n-1\$(2^n-1,0,0)\$,0)$ \$(0,2^n-1,0)\$, and $(0,0,2^n-1)$\$(0,0,2^n-1)\$.)

Let $s_2(n)$\$s_2(n)\$ refer to the number of 1s in the binary expansion of $n$\$n\$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon $(x,y,z)$\$(x,y,z)\$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including $n=10$\$n=10\$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

Write a program that, for any $n$, generates a triangle made of hexagons as shown, $2^n$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple $(x,y,z)$ with $x+y+z=2^n-1$. (The three corners will be $(2^n-1,0,0)$, $(0,2^n-1,0)$, and $(0,0,2^n-1)$.)

Let $s_2(n)$ refer to the number of 1s in the binary expansion of $n$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon $(x,y,z)$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including $n=10$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

Write a program that, for any \$n\$, generates a triangle made of hexagons as shown, \$2^n\$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple \$(x,y,z)\$ with \$x+y+z=2^n-1\$. (The three corners will be \$(2^n-1,0,0)\$, \$(0,2^n-1,0)\$, and \$(0,0,2^n-1)\$.)

Let \$s_2(n)\$ refer to the number of 1s in the binary expansion of \$n\$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon \$(x,y,z)\$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including \$n=10\$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here

Source Link

Create a triangle whose colors are determined by the bitsums of coordinates

Write a program that, for any $n$, generates a triangle made of hexagons as shown, $2^n$ to a side. The colors are to be determined as follows.

We may give the triangle barycentric coordinates so that every hexagon is described by a triple $(x,y,z)$ with $x+y+z=2^n-1$. (The three corners will be $(2^n-1,0,0)$, $(0,2^n-1,0)$, and $(0,0,2^n-1)$.)

Let $s_2(n)$ refer to the number of 1s in the binary expansion of $n$. (This is sometimes called the bitsum or the popcount function.) If $$s_2(x)+s_2(y)+s_3(z)\equiv n\pmod 2$$ then color the hexagon $(x,y,z)$ in a light color; otherwise, color it in a dark color. (These must be colors, not simply black and white.)

In your answer, I would appreciate seeing several example outputs, ideally including $n=10$.

This is my first post here, so I apologize if I misunderstand the rules somehow. enter image description here