Blocks in an Irregular Pyramid
Description:
Consider a pyramid made up of blocks. Each layer of the pyramid is a rectangle of blocks, and the dimensions of these rectangles increment as you descend the pyramid. So, if a layer is a 3x6
rectangle of blocks, then the next layer will be a 4x7
rectangle of blocks. A 1x10
layer will be on top of a 2x11
layer on top of a 3x12
layer, and so on.
Task
Given the dimensions of a pyramid's topmost layer w,l
, and its height h
(aka the number of layers), return the total number of blocks in the pyramid.
Examples
num_blocks(1, 1, 2)
will return 5
. This pyramid starts with a 1x1
layer and has 2 layers total. So, there is 1 block in the first layer, and 2x2=4
blocks in the second. Thus, 5 is the total number of blocks.
num_blocks(2, 4, 3)
will return 47
. This pyramid has 3 layers: 2x4
, 3x5
, and 4x6
. So, there are 47
blocks total.
Notes
All parameters will always be postive nonzero integers.
Efficiency is important. There will be:
- 100 'small' cases with
w
,l
, andh
below20
. - 100 'big' cases with
w
,l
, andh
between1e9
and1e10
.
Similar Kata:
Stats:
Created | Apr 5, 2019 |
Published | Apr 5, 2019 |
Warriors Trained | 1909 |
Total Skips | 186 |
Total Code Submissions | 3780 |
Total Times Completed | 520 |
Python Completions | 212 |
JavaScript Completions | 124 |
Ruby Completions | 32 |
C++ Completions | 107 |
C Completions | 40 |
COBOL Completions | 7 |
SQL Completions | 90 |
Total Stars | 39 |
% of votes with a positive feedback rating | 83% of 110 |
Total "Very Satisfied" Votes | 81 |
Total "Somewhat Satisfied" Votes | 20 |
Total "Not Satisfied" Votes | 9 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |