Back
Close

Pyramid of cannonballs

Statement

 Goal

A pirate stacks his cannonballs in a pyramid. There is only one at the top of the pile. The cannonballs nest on top of each other; for a two-tiered pyramid, there are five cannonballs: four at the bottom, arranged in a square, and one at the top. Each tier is a square with a side length one unit larger than the tier above.

Calculate how many levels the pyramid would have if the pirate had N cannonballs to stack. If the given number of cannonballs does not make a perfect pyramid, print cannonball in the sea!
Input
An integer N : for the number of cannonballs to be arranged in a pyramid.
Output
Line 1 : the number of levels in the pyramid based on the number of cannonballs given by N, or cannonball in the sea!.
Constraints
1 < N ≤ 70000
Example
Input
5
Output
2

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5
Output
2

Validator 1 Validator
Input
14
Output
3

Test 2 Test
Input
650
Output
12

Validator 2 Validator
Input
819
Output
13

Test 3 Test
Input
63365
Output
57

Validator 3 Validator
Input
60116
Output
56

Test 4 Test
Input
54321
Output
cannonball in the sea!

Validator 4 Validator
Input
12345
Output
cannonball in the sea!

Solution language

Solution

Stub generator input