Problem A

Solution :

Following is the mapping of alphabets:

{‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’}=>{‘y’,’h’,’e’,’s’,’o’,’c’,’v’,’x’,’d’,’u’,’i’,’g’,’l’,’b’,’k’,’r’,’z’,’t’,’n’,’w’,’j’,’p’,’f’,’m’,’a’,’q’}

Traverse for each character in input string and replace it with the mapped alphabet

Solution can be downloaded from here

Problem B

Solution:

For each score

avgScore = score/3;

difference = score – avgScore * 3;

if difference is 0 , best score is avgScore + 1 if its a surprised score else best score is avgScore

if difference is 1, best score is avgScore+1

if difference is 2, best score is avgScore + 2 if its surprised else its best score is avgScore+1

for each difference, keep count of scores for which best score is greater than or equal to P without being a surprised score

also for each difference, keep count of scores for which best score is greater than or equal to P with being a surprised score

answer will be pure_surprised_score + score>=P_without_being_surprised

Solution can be downloaded from here

Problem C

Solution :

Read A and B

Create a large array Arr of integers of size as that of the given range and initialize it to zero

For each X=A to X=B

recycle X to form the smallest no. T from digits of X

increment value of Arr[T] by 1

End For

Ans = 0

For count=0 to Size Of Arr

Ans += Arr[count] *(Arr[count]-1)/2 //combination of n occurrences of a recycled no. taking 2 at a time

End For

Return Ans

Solution Can be downloaded from here

### Like this:

Like Loading...

*Related*