Matchsticks to Square - Leetcode 473 - Python