6 kyu
Brick pyramid.
70 of 310intmainvoid
Description:
Brick "pyramid".
"Pyramid" is infinite.
"Pyramid" is two-dimensional (triangle).
(row, pos) - function parameters.
row - top row number ranging from zero,
pos - brick number from left to right ranging from zero.

Brick weight - 1 kg.
Every brick equally presses the bricks underneath.
1/2 to the left brick and 1/2 to the right.

If the brick pressed above with the total mass of 100 kg than the pressure is distributed evenly on the bottom bricks.

Required: implement function weight that calculates the pressure on the brick on the row, pos position.
Testing values:
weight(0, 0) => 0
weight(1, 0) => 0.5
weight(1, 1) => 0.5
weight(2, 0) => 0.75
weight(2, 1) => 1.5
weight(2, 2) => 0.75
weight(3, 0) => 0.875
weight(3, 1) => 2.125
weight(3, 2) => 2.125
weight(3, 3) => 0.875
Algorithms
Similar Kata:
Stats:
Created | Nov 24, 2016 |
Published | Nov 24, 2016 |
Warriors Trained | 938 |
Total Skips | 192 |
Total Code Submissions | 1425 |
Total Times Completed | 310 |
JavaScript Completions | 70 |
PHP Completions | 24 |
C Completions | 111 |
C++ Completions | 68 |
C# Completions | 30 |
Java Completions | 50 |
Total Stars | 30 |
% of votes with a positive feedback rating | 87% of 98 |
Total "Very Satisfied" Votes | 79 |
Total "Somewhat Satisfied" Votes | 13 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 11 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |