Saturday, October 21, 2017

Adamant Kid

An adamant kid keeps on repeating the stuff he wants. Like if the kid wants chocolate he keeps repeating "chocolate". Given the stuff the child is demanding the program must print if the character in two given positions X, Y is same or not by printing YES or NO. Input Format: First line will contain the name of the stuff as a string value S. Second line will contain two integer values...
Share:

Sort Numbers - Factor Count

The program must accept N positive integers as the input and sort them based on the factor count (lowest to highest factor count). If two numbers have the same factor count, order based on the value of the numbers in the ascending order. Input Format: The first line will contain N. The second line will contain N positive integers separated by a space. Output Format: The first line will...
Share:

Thursday, October 19, 2017

Sean's Encryption Quest!

One-day Sean's friend John wanted him to encrypt a few messages that were to be sent via a TELEGRAM group, so that everyone could see the message, but only those special people who knew decryption can actually understand it. Help Sean write a code that take input values of the type of encryption, a key, and a message to be encrypted that had something to do with the key. Input Format: First...
Share:

Reverse & Print Common Characters

Two string values S1 and S2 are passed as the input. Reverse string S2 and print the letters which are common in a given index. The letters in S1 and S2 will be in lower case. Input Format: The first line contains S1. The second line contains S2. Output Format: The first line contains the letters which are common after S2 is reversed. Boundary Conditions: 2 <= Length of S1 <=...
Share:

Jersey Number - Highest in Team

In a school there are N students standing in a straight line. Their Jersey numbers from left to right are passed as the input. The students are to be divided into teams of size T starting from left. First T students form Team 1, next T students form Team 2 and so on. If N is not divisible by T and say the remainder is R, the R students are distributed among the teams formed so far in a round robin...
Share:

Immediate Previous Larger Number

N numbers are passed as input to the program. The program must print the immediate previous larger number. If there is no such larger number print 0 for that specific number. Note: As N can be as high as 100000, optimize your algorithm to avoid timeout. Input Format: The first line contains N. The second line contains N numbers separated by a space. Output Format: The first line contains...
Share:

Pattern Printing - Half Pyramid Numbers

The number of rows N is passed as the input. The program must print the half pyramid using the numbers from 1 to N. Input Format: The first line contains N. Output Format: N lines representing the half pyramid pattern using the numbers from 1 to N. (A single space is used to separate the numbers) Boundary Conditions: 2 <= N <= 100 Example Input/Output 1: Input:...
Share:

Punctuality Incentive

The CEO of company ABC Inc wanted to encourage the employees coming on time to the office. So, he announced that for every consecutive day an employee comes on time in a week (starting from Monday to Saturday), he will be awarded Rs.200 more than the previous day as "Punctuality Incentive". The incentive I for the starting day (i.e. on Monday) is passed as the input to the program. The number...
Share:

Saturday, October 14, 2017

Meeting Late Comers

A certain number of people attended a meeting which was to begin at 10:00 am on a given day. The arrival time in HH:MM format of those who attended the meeting is passed as the input in a single line, with each arrival time by a space. The program must print the count of people who came late (after 10:00 am) to the meeting. Input Format: The first line contains the arrival time separated by...
Share:

Thursday, October 12, 2017

Digit In Tenth Position

The program must accept a positive integer N and print the digit in the tenth position. Input Format: The first line denotes the value of N. Output Format: The first line contains the value of N. Boundary Conditions: 10 <= N <= 9999999 Example Input/Output 1: Input: 20 Output: 2 Example Input/Output 2: Input: 37843 Output: 4 Solution 1: print(int(int(input())/10)%10) Solution 2: #include...
Share:

Wednesday, October 11, 2017

First Five Values Divisible

Three numbers A, B and C are passed as input. The program must print the first five values that are divisible by A, B and C. Input Format: The first line denotes the value of A. The second line denotes the value of B. The third line denotes the value of C. Output Format: The first line contains the first five numbers divisible by A, B and C (with each value separated by a space). Boundary Conditions: 1...
Share:

Tuesday, October 10, 2017

Toggle Alphabet Case

The program must accept an alphabet X and toggle the case (convert upper case to lower case and vice versa). Input Format: The first line denotes the value of character X. Output Format: The first line contains the characters X and the toggled case character separated by a hyphen. Boundary Conditions: X is from a to z Example Input/Output: Input: d Output: d-D Sol...
Share:

Interlace odd-even from A to B

Two numbers A and B are passed as input. The program must print the odd numbers from A to B (inclusive of A and B) interlaced with the even numbers from B to A. Input Format: The first line denotes the value of A. The second line denotes the value of B. Output Format: The odd and even numbers interlaced, each separated by a space. Boundary Conditions: 1 <= A <= 9999999 A <...
Share:

Print Calendar Month in Words

The program must accept an integer value N and print the corresponding calendar month in words. 1 - January, 2 - February, .... , 11 - November, 12 - December If any value apart from 1 to 12 is passed as input, the program must print "Invalid Input". Input Format: The first line denotes the value of N. Output Format: The first line contains the output as per the description. (The output...
Share: