6 kyu
Counting hexagons
48 of 53vlukyanets
Description:
An equilateral triangle with integer side length n>=3
is divided into n^2
equilateral triangles with side length 1 as shown in the diagram below.
The vertices of these triangles constitute a triangular lattice with (n+1)(n+2)/2
lattice points.
Base triangle for n=3
:
Last regular hexagon for n=6
:
Let H(n)
be the number of all regular hexagons that can be found by connecting 6 of these points. For example, H(3)=1
, H(6)=12
and H(20)=966
.
Create function counting_hexagons
that calculates H(n)
where 3 <= n <= 40000
.
Solution size should be less than 8KB.
Javascript: use BigInt
Adopted from projecteuler.net
Mathematics
Puzzles
Similar Kata:
Stats:
Created | Jul 11, 2021 |
Published | Jul 21, 2021 |
Warriors Trained | 362 |
Total Skips | 9 |
Total Code Submissions | 516 |
Total Times Completed | 53 |
Python Completions | 48 |
JavaScript Completions | 15 |
Total Stars | 19 |
% of votes with a positive feedback rating | 85% of 24 |
Total "Very Satisfied" Votes | 18 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 3 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |