Back
Close

Pyramid pieces

Statement

 Goal

An artist wants to paint a pyramid using his own algorithm.
He needs to know the number of the "stone" which is above right or left of the one he is painting.
Each "stone" of the pyramid are numbered from left to right, stage by stage starting from the top. The one at the top is stone n ° 1, on the floor below there is n ° 2 and n ° 3 ...
........[-1-]........
.....[-2-][-3-]....
.[-4-][-5-][-6-].
Input
Line 1 : The name of the stone that we want to paint .
Line 2 : Are we looking for the name of the stone that is up LEFT side or up RIGHT side.
Output
Line 1 :The N of the stone that we are looking for if it exist. if not return "EMPTY"
Constraints
1 ≤ Name ≤ 10000
Example
Input
2
RIGHT
Output
1

Tags
LoopsLogical problem

Difficulty
Easy

Test cases
Top right Test
Input
2 RIGHT
Output
1

Top right Validator
Input
2 RIGHT
Output
1

Top Left Test
Input
3 LEFT
Output
1

Top Left Validator
Input
3 LEFT
Output
1

Void Test
Input
2 LEFT
Output
EMPTY

Void Validator
Input
2 LEFT
Output
EMPTY

Medium left Test
Input
7 RIGHT
Output
4

Medium left Validator
Input
11 RIGHT
Output
7

Medium Test
Input
8 RIGHT
Output
5

Medium Validator
Input
9 RIGHT
Output
6

Medium right Test
Input
10 LEFT
Output
6

Medium right Validator
Input
15 LEFT
Output
10

Far away Test
Input
30 LEFT
Output
22

Far away Validator
Input
31 LEFT
Output
23

Far away 2 Test
Input
18 RIGHT
Output
13

Far away 2 Validator
Input
24 RIGHT
Output
18

Over the cliff Test
Input
28 RIGHT
Output
EMPTY

Over the cliff Validator
Input
36 RIGHT
Output
EMPTY

End Game Test
Input
20000 LEFT
Output
19800

End Game Validator
Input
19882 LEFT
Output
19683

Solution language

Solution

Stub generator input