Beta
Pharaoh's pyramid of sum
10Rei_00
Description:
Introduction
Ancient Egypt is thriving! The number of pyramid projects is increasing!
Help the priests to make the right order to the stone quarry, without resorting to the costly ritual of patronage of the goddess Seshat.
Each dynasty of pharaohs built a larger pyramid than before, however, the total height n
of the pyramid remains the same.
So have to increase the width: count of blocks for level i
of new generation is sum of blocks from levels 0,..,i
by previous dynasty.
First dynasty (numbering starts from 1) looks at forerunners
IN & OUT
Function pyramid_cost
get:
data
- integer array of forerunner pyramid:data[i]
- count of block's on their leveli
(0 <= i < n, n < 10^6
)k
- number of dynasty which pyramid you need calculate:1 <= k < 10^6
p
- prime number:n < p < 10^9
You need to return the total number of blocks for pyramid of given dynasty modulo p
Example
IN: data = [a, b, c, d]
dynasty = 3
p = 11
SOLVE:
levels | 0 | 1 | 2 | 3
------------|-----|----------|---------------|---------------------
forerunners | a | b | c | d
------------|-----|----------|---------------|---------------------
I dynasty | a | a + b | a + b + c | a + b + c + d
II dynasty | a | 2a + b | 3a + 2b + c | 4a + 3b + 2c + d
III dynasty | a | 3a + b | 6a + 3b + c | 10a + 6b + 3c + d
OUT: ( (a) + (3a+b) + (6a+3b+c) + (10a+6b+3c+d) ) % 11
Mathematics
Performance
Similar Kata:
Stats:
Created | Apr 9, 2024 |
Published | Apr 14, 2024 |
Warriors Trained | 27 |
Total Skips | 0 |
Total Code Submissions | 61 |
Total Times Completed | 10 |
Python Completions | 10 |
Total Stars | 3 |
% of votes with a positive feedback rating | 92% of 6 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 7 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |