Q1 :

The Game of Book Cricket is played by 2 players. Each player randomly opens the book and as you open the pages you score runs. The last digit of the even numbered page corresponds to your score.

So if you opened page number 236, your score is 6. Hence possible scores are either 0,2,4,6 or 8. However if the number ends with a 0 or 8, you are out and you lose your turn. Every time you open the book, note the score and keep on adding. So if you opened pages 124, 56, 22 your score is 4 +6 +2= 12.

Given that player 1 has scored N(totalScore) runs and the number of pages in the book is only 10, your task is to identify the number of ways you can match the score and remain not out?

Input:

totalScore(N): Total score of the first player

Example:

Sample

Input: 6

Output: 4

Explanation:

6 can be reached by the following combinations

[2,2,2]

[2,4] [4,2]

[6]

Q2 :

Number Patterns & finding the possible smallest numeric value

Question:

Given a Pattern containing only Ns and M’s . N represents ascending and M represents descending , Each character (M or N) needs to display sequence of numbers(2 numbers) explaining the ascending or descending order (for ex: 21 ->represents descending -> M) . The second character in the pattern takes the last digit from first character and builds the sequence and so on..Please look at example section below.

There could be multiple numbers satisfying the pattern. The goal is to find out the lowest numeric value following the pattern.

Constraints:

Input can have maximum 8 characters

Output can have Digits from 1-9 and Digits can’t repeat.

In case of no possible output or incorrect input value (like blank /null /NON M or N character) please return -1.

Example Section:

Input : M

Output: 21 (2 -> 1 shows descending and possible smallest numeric value. Even 65 or 74 can qualify, but 21 being the smallest numeric value is the correct answer)

Input : MNM

Output:2143 (M represents descending 2->1 , N represents ascending 1->4 (1 is coming from last character) , M represents descending 4->3(4 is coming from last character sequence) — There would be many number qualifying the pattern like 3142 ,8796,6241 etc.. 2143 is the lowest numeric value for this pattern sequence.)