INTERACTIVE CODING PROBLEMS

                        INTERACTIVE CODING PROBLEMS

1.                                                MAIRA AND SURPRISE GIFT                                                         


To attract more people to attend the weekend party in the Rajkot grounds, Maira's team has decided to give many attractive surprise gifts like headphones, USB drives, scratch guards, mobile accessories.
Maira is very fond of the number 40 and she decides to give surprise gifts to all people whose ticket number is a multiple of 40 or is 1 or 2 away from the multiple of 40. (Examples : 38, 39, 40, 41, 42, 81 ....).

Can you please help Maira in determining the surprise gift winners?


Input Format:

Input consists of a single integer that corresponds to the ticket number.

Output Format:

The output consists of a string --- “Winner” or “Not A Winner” or “Invalid Input”.


If the input integer is less than 1 or greater than 6000, print Invalid Input.

Sample Input 1:
42

Sample Output 1:
Winner

Sample Input 2:
52

Sample Output 2:
Not A Winner

Sample Input 3:
-42

Sample Output 3:
Invalid Input

SOLUTION:-

#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
if ((n<1) || (n>6000))
printf("Invalid Input\n");
else if((n%40==0)||((n+1)%40==0)||((n+2)%40==0)||((n-1)%40==0)||((n-2)%40==0))
printf("Winner\n");
else
printf("Not A Winner\n");
return 0;
}



  2.                                                Taichi’s Kung Fu Match                                                                    

Taichi is glad as his academy of martial arts is chosen to present a warm-up match of Kung Fu at the inaugural ceremony of the Summer Olympics.

There are 'n' Kung Fu fighters in Taichi’s academy.

Taichi is very particular in selecting two fierce Kung Fu fighters from his academy who are going to put up a thrilling close competitive performance at the ceremony.

For this purpose, he fetches the details of the winning points of all 'n' fighters in his academy and stores it in an array.
He should now select the two fighters who have scored almost the same win percentages so far, as they would make the audience exhilarating till the end.

Your aim is to help Taichi find the difference in win percentages between two fighters chosen for the warm-up match.

Examples:
Input  :  If n = 4 and winPoints[] = {30,5,20,9}
Output :  4

Input Format:
The first line of the input consists of an integer n, which corresponds to the number of fighters in Taichi’s academy. Assume that the maximum number of input elements in the array is 50.
The next 'n' lines in the input corresponding to the winning points of each of the fighter.
Output Format:
The output is an integer – difference between two fighters chosen for the warm-up match.

Refer sample input and output for formatting specifications.

Sample Input1:
6
1
5
3
19
18
25
Sample Output1:
1

SOLUTION:-

#include<stdio.h>
int main()
{
    int n,a[50],i,j,t=0,md=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<(n-i-1);j++)
        {
            if(a[j]<a[j+1])
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    md=a[0];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]-a[j]<md)
            {
                md=a[i]-a[j];
            }
        }
    }
    printf("%d",md);
    return 0;
}


 3.                            RENOVATION OF COLLEGE LIBRARY                                                          

The College Library is to be elaborately renovated owing to its 100 th year anniversary celebrations. It is one of the oldest libraries in the state and has been a symbol of legacy.

The Library management wanted to rebuild the steel bookracks in the building and renumber them thereafter.

Each of the  n racks should be assigned with a number from 1 to  n. It is very obvious that each rack should be assigned distinct numbers.


Jack, a craftsman was assigned the task of renumbering the racks with his artistic carving.

He normally charges wages based on the number of carvings he does. While numbering the racks, he treats each carving of the digit in the numbers of the racks for wages. Hence he wanted to keep a note of how many such digits he is carvings.

For example,
If n = 13, the racks get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 carvings.



Input Format:
The first line contains integer  n, which corresponds to the number of bookracks in the library.

Output Format:
Print the number of carvings that Jack does to number all the bookracks.

Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output.]


Sample Input1:
13
Sample Output1:
17

Sample Input2:
4
Sample Output2:
4

SOLUTION:-
#include<stdio.h>
int main(void)
{
    int i,n,k,count=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        k=i;
        while(k!=0)
        {
            k=k/10;
                count++;

        }

    }
    printf("%d",count);
    return 0;
}