| about | help | code help+videos | done | prefs |
nrectangles
Consider a rectangular grid of size W squares wide by H squares high. It can fit a number of smaller rectangles inside. For example, a 3 wide by 2 high grid can fit 6 1x1 rectangles, 2 2x2 rectangles (one up against the left side, one against the right), 2 3x1 rectangles (the top row and the bottom row), 1 3x2 rectangle (ok, that one is not smaller, but we'll count it anyways), 4 2x1 rectangles and 3 1x2 rectangles, for a total of 18. Write nrectangles(W, H) to return the total number of rectangles that can fit in an W x H grid. nrectangles(3, 2) → 18 nrectangles(1, 10) → 55 nrectangles(1, 1) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300 Post-solution available
Copyright Nick Parlante 2017 - privacy