Optimizing Box Weights Hackerrank Solution Python Snake