curriculum/challenges/english/blocks/daily-coding-challenges-python/68f6587287ad1f4ad39b0c84.md
Given two positive integers representing the width and height of a rectangle, determine how many rectangles can fit in the given one.
For example, given 1 and 3, return 6. Three 1x1 rectangles, two 1x2 rectangles, and one 1x3 rectangle.
count_rectangles(1, 3) should return 6.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_rectangles(1, 3), 6)`)
}})
count_rectangles(3, 2) should return 18.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_rectangles(3, 2), 18)`)
}})
count_rectangles(1, 2) should return 3.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_rectangles(1, 2), 3)`)
}})
count_rectangles(5, 4) should return 150.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_rectangles(5, 4), 150)`)
}})
count_rectangles(11, 19) should return 12540.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_rectangles(11, 19), 12540)`)
}})
def count_rectangles(width, height):
return width
def count_rectangles(width, height):
total = 0
for w in range(1, width + 1):
for h in range(1, height + 1):
total += (width - w + 1) * (height - h + 1)
return total