Hexagon and Square

A problem from brilliant.org