7 kyu

T.T.T.48: Make a rectangular cup that has maximum volume

Description:

Description

We have a piece of cardboard square, side length is n cm. We use it to make a cuboid cup(The five side is paper, one side is empty):

_____________________________
|                           |
|                           |
|                           |
|                           |
|                           |
|                           |
|                           |
|___________________________|

First we need to cut four identical small squares in the four corners of the cardboard.

           _______________
      cut  |             |  cut
     ______|             |______
    |                           |
    |                           |
    |                           |
    |______              _______|
           |             |
      cut  |_____________|  cut

Then the four protruding part is folded upwards, a rectangular cup is made.

We can assume that the length of the small square is an integer. Please calculate, how much is the maximum volume of the cup we made?

Task

Complete function maximumVolume() that accepts a arguments n(a positive integer more than 4). Returns the maximum volume of the cup.

Example

maximumVolume(5)  === 9
3 * 3 * 1 = 9
maximumVolume(6)  === 16
4 * 4 * 1 = 16
maximumVolume(7)  === 25
5 * 5 * 1 = 25
maximumVolume(8)  === 36
6 * 6 * 1 = 36
maximumVolume(9)  === 50
5 * 5 * 2 = 50
maximumVolume(10)  === 72
6 * 6 * 2 = 72
maximumVolume(20)  === 588
14 * 14 * 3 = 588
Puzzles
Games

Stats:

CreatedAug 25, 2016
PublishedAug 25, 2016
Warriors Trained285
Total Skips18
Total Code Submissions360
Total Times Completed133
JavaScript Completions133
Total Stars6
% of votes with a positive feedback rating89% of 47
Total "Very Satisfied" Votes40
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes3
Total Rank Assessments6
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • Voile Avatar
Ad