7 kyu
[Code Golf] Number Pyramid Series 1 - Sum of Corners
242LanXnHn
Description:
Number Pyramid
Image a number pyramid starts with 1
, and the numbers increasing by 1
.
For example, when the pyramid has 3 levels:
1
2 3
4 5 6
And the sum of three corners are:
1 + 4 + 6 = 11
Input:
You will be given a number n
, which means how many levels the pyramid has.
0 <= n <= 5000
Output:
You need to return the sum of three corners of the pyramid.
When there is no level, return
0
as there is no corner.When there is only one level, return
1
as it is the only corner.
Examples:
sum_corners(0) --> 0
sum_corners(1) --> 1
sum_corners(2) --> 6
sum_corners(3) --> 11
Golfing Message:
The length of your code should be less or equal to 35
.
If you like this series, welcome to do other kata of it.
Mathematics
Restricted
Similar Kata:
Stats:
Created | Jul 5, 2022 |
Published | Jul 6, 2022 |
Warriors Trained | 667 |
Total Skips | 11 |
Total Code Submissions | 1642 |
Total Times Completed | 242 |
Python Completions | 242 |
Total Stars | 12 |
% of votes with a positive feedback rating | 87% of 84 |
Total "Very Satisfied" Votes | 67 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 26 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |