# C++ using SFML, <s>722</s> <s>703</s> 683 bytes # -19 bytes thanks to NoLongerBreathedIn, using __builtin_popcount removes needing a bitsum function. Might work only for GCC. -20 bytes, I used the using keyword for namespaces and components, and stopped using `.f` for magic numbers [SFML][1] is a library that helps with the development of graphical / audio / network applications. There's probably some golfing optimization to be done using macros here and there. It has 2 functions, the `s(int)` function computes positions on the screen of the hexagons and their color, and returns a structure composed of the x and y coordinates, and a boolean that is true for light color and false for dark color. <!-- language: lang-cpp --> #include <cmath> #include <vector> #include <SFML/Graphics.hpp> #define B(c) __builtin_popcount(c) using namespace sf;struct t{double x,y;bool b;};using V=std::vector<t>;V d(int n){double r=5;int x,y,z,w=pow(2,n);V o;for(x=0;x<w;++x)for(y=0;y<w-x;++y){z=w-1-x-y;o.push_back({-cos(7*M_PI/6)*(r*y-r*z),r*x-(r*y+r*z)/2,(B(x)+B(y)+B(z))%2==n%2});}return o;}int v(int n){RenderWindow w(VideoMode(1200,1000),"");CircleShape h(4,6);;auto v=d(n);while(w.isOpen()){Event event;while(w.pollEvent(event))if(event.type==Event::Closed)w.close();w.clear();for(auto&a:v){h.setPosition(a.x,-a.y);h.setOrigin(-600,-650);h.setFillColor(a.b?Color::Yellow:Color::Blue);w.draw(h);}w.display();}return 0;} Function to call in the main is `v(int)` with the parameter being n, the number `n` <!-- language: lang-cpp --> int main() { return v(6); } Compile with : `g++ source.cpp -lsfml-graphics -lsfml-window -lsfml-system` Run with : `./a.out` Due to the screen size and the fact that hexagons have to be visible, the size of a n=10 triangle can't be seen fully in a 'normal' sized screen, triangle is fully visible in the screen at n<=7. Size of hexagon and space between them can be configured in the `d(int)` function with variable `r` and `v(int)` function by modifying the first parameter of the constructor of the `h` variable (the CircleShape object), that value being the radius of the circle. Be free to modify those parameters to draw bigger hexagons on the screens, `r` should be slightly bigger that the circle's radius Here is an image of the result for `n=6` [![Triangle for N=6][2]][2] [1]: https://www.sfml-dev.org/index.php [2]: https://i.sstatic.net/8XwkZ.png