Fundamentals
Puzzles
Games
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Simple tests") def test_group(): @test.it("Test 1") def test_case1(): test.assert_equals(minimal_square(2, 3), 16) @test.it("Test 2") def test_case2(): test.assert_equals(minimal_square(3, 7), 49)
Fundamentals
Puzzles
Games
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
andb
with1 <= 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
import codewars_test as test
# TODO Write tests
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Simple tests")
def test_group():
@test.it("Test 1")
def test_case1():
test.assert_equals(minimal_square(2, 3), 16)
@test.it("Test 2")
def test_case2():
test.assert_equals(minimal_square(3, 7), 49)