5 kyu

Castle of Cubes

Description:

Castle of Cubes:

You've been hired by a castle building company.
Their procedure is very simple : In their castles, all the rooms are the same cube.
They build thousands of the same square stone panels, and assemble them (ground,walls,ceiling).
Neighboring rooms share one same panel between them.
Business is growing fast, so they need your help:
the customer has only one variable: 'n', the number of rooms.
For energy saving reasons, the surface of the castle must be minimum for any given 'n'.
Multiple floors are possible.

You must write a code to find the number of panels that will be needed for a 'n' castle.
(Optimised solution is needed: there are 100 000+ tests, in a range from 0 to 10^18)

ex:
n - pannels:
0 - 0
1 - 6
2 - 11
36 - 141
37 - 146

Algorithms

Similar Kata:

Stats:

CreatedApr 21, 2019
PublishedApr 26, 2019
Warriors Trained264
Total Skips13
Total Code Submissions758
Total Times Completed32
Python Completions32
Total Stars19
% of votes with a positive feedback rating100% of 13
Total "Very Satisfied" Votes13
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments3
Average Assessed Rank
4 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Cépagrave Avatar
  • Hippunky Avatar
Ad