Solution for min perimeter rectangle