Project Euler 189 - Tri-colouring a triangular grid

Official link: https://projecteuler.net/problem=189