Proper solution of Triangle task