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

Stats:

CreatedNov 24, 2016
PublishedNov 24, 2016
Warriors Trained938
Total Skips192
Total Code Submissions1425
Total Times Completed310
JavaScript Completions70
PHP Completions24
C Completions111
C++ Completions68
C# Completions30
Java Completions50
Total Stars30
% of votes with a positive feedback rating87% of 98
Total "Very Satisfied" Votes79
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes6
Total Rank Assessments11
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • intmainvoid Avatar
  • smile67 Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
Ad