Ad
Fundamentals
Puzzles
Games
Code
Diff
  • def minimal_square(a, b):
        return max(min(a, b)*2, max(a, b))**2
Fundamentals
Puzzles
Games
Code
Diff
  • def minimal_square(a, b):
        return max(min(a, b)*2, max(a, b))**2
    # This is my first kumite (∩_∩)
    # I think this is the best solution there's not much to improve on
    # The problem isn't too hard
    • def minimal_square(a, b):
    • return max(min(a, b)*2, max(a, b))**2
    • //This is cool//
    • return max(min(a, b)*2, max(a, b))**2
    • # This is my first kumite (∩_∩)
    • # I think this is the best solution there's not much to improve on
    • # The problem isn't too hard
Fundamentals
Puzzles
Games

Your task is to find the minimum SQUARE area in which you can place two identical rectangles. The sides of the rectangles should be parallel to the sides of the square.

  • You are given two identical rectangles with side lengths a and b with 1 <= a, b <= 100.
  • Find the square with minimum area that contains both given rectangles. Rectangles can be rotated (both or just one) and moved, but the sides of the rectangles should be parallel to the sides of the desired square.
def minimal_square(a, b):
    return max(min(a, b)*2, max(a, b))**2