Special Fruit Tree codechef solution
There exists a unique tree in Rahul’s farm that bears Apples and Bananas as its fruits. This tree bear fruits in accordance with the following rules :
- Every fruit has two children.
- The first child of Banana is a Banana and the second child is an Apple.
- The first child of Apple is an Apple and second child is a Banana.
- All the generations of Apples and Bananas start with an Apple.
A visual Representation of Tree is as follows :
A / \ A B / \ / \ A B B A
Given the level and position of a fruit determine if it an Apple or a Banana.
Point to Note: Special Fruit Tree codechef solution
- The first child is considered as the left child and second as right.
- The level of a fruit in the Special Fruit tree is 1-based.
- The position of a fruit in the given level of Special Fruit tree is 1-based, counting from left to right.
Single line of input, two integers Level and Position.
For each pair of inputs , output is a single line containing either “Apple” or “Banana”. Outputs that are case insensitive i.e. “APple” ,”APPLE”,”BaNAna” ,etc are correct too but “Apples”, “Bananas” is not.
Constraints: Special Fruit Tree codechef solution
1 ≤ level ≤ 30
1 ≤ position ≤ 2^( level – 1)
Sample Input 1
Sample Output 1 Special Fruit Tree codechef solution
Sample Input 2
Sample Output 2
Also Read –Best Diet after fibroadenoma surgery 2021