Problem (1): Vowel Reduction

advertisement
Problem (1): Vowel Reduction
It is very well known that a person can read easily a sentence after
removing all the vowels from it. Try by yourself for example the sentence
“IT-Mrthn s fn” and you will discover that the sentence is “IT-Marathon
is fun”. Your job is to write a program to remove all lower case vowels
from a sentence.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by a paragraph.
Output:
For each instance of the problem given as input, display the
paragraph correctly by removing all lower case vowels from the
sentence.
Sample input:
-----------3
IT-Marathon is Fun.
This is the vowel reduction problem.
You are competing with pride.
IT Marathon Contest 2012
Resultant output:
---------------IT-Mrthn s Fn.
Ths s th vwl rdctn prblm.
Y r cmptng wth prd.
Programming
Page 1
Problem (2): One Space
Spacy is good in typing, however, he has problem in holding the space bar
longer than enough. This results in a more than one space between words.
Your task is to help Spacy to reduce multiple spaces in a paragraph into
one space.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by a paragraph. Notice that in the
example below, spaces are represented by ‘-‘ to show number of spaces
in the sentence.
Output:
For each instance of the problem given as input, display the
paragraph correctly by removing the multiple spaces.
Sample input:
Resultant output:
--------------------------3
Spacy is a very fast typist.
Spacy---is—a-very----fast-----typist-. ITMarathon is wonderful and nice.
ITMarathon-is--wonderful-and--nice.
Have fun.
Have-fun------.
IT Marathon Contest 2012
Programming
Page 2
Problem (3): Inside Rectangle Points
Given two points in 2 dimensional space representing the upper left and
lower right corners of a rectangle, write a program to determine whether
a point is inside, on, or outside the rectangle. For example, given the
rectangle below identified by (x1,y1) and (x2,y2), p1 is inside the
rectangle, p2 is outside the rectangle, and p3 is on the rectangle.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by 6 integers representing 2 points. The
first two are the upper left and lower right corners of the rectangle.
The third point is the point we want to check whether it is inside, on,
outside the rectangle.
Output:
For each instance of the problem given as input, display on a
single line the words inside, on, or outside.
Sample input:
-----------5
0 4 8 2 3 3
0 4 8 2 4 4
0 4 8 2 2 1
1 4 3 -1 1 3
1 4 3 -1 2 0
IT Marathon Contest 2012
Resultant output:
---------------inside
on
outside
on
inside
Programming
Page 3
Problem (4): Is Sorted
Given a sequence of numbers, determine if the numbers are sorted in
ascending order or not.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by a sequence of numbers space separated.
The first number of the sequence is the length of the sequence
Output:
For each instance of the problem given as input, display on a
single line the words Sorted or Not Sorted.
Sample input:
-----------5
5 4 8 12 33 33
3 4 4 8
6 4 8 12 12 11 20
5 44 13 11 10 3
1 4
IT Marathon Contest 2012
Resultant output:
---------------Sorted
Sorted
Not Sorted
Not Sorted
Sorted
Programming
Page 4
Problem (5): Strange Numbers
A strange number is a number that is greater than 9 and its digits product
is divisible by its digits sum. For example, 123 is a strange number
because (1*2*3) / (1+2+3) =6/6=1, while 23 is not a strange number because
(2*3)/(2+3)=6/5=1.2 (not an integer). Given a number M, identify whether
M is strange or not.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by a number M.
Output:
For each instance of the problem given as input, display on a
single line the words Strange or Not Strange.
Sample input:
-----------4
1234
246
635
9
IT Marathon Contest 2012
Resultant output:
---------------Not Strange
Strange
Not Strange
Not Strange
Programming
Page 5
Problem (6): Even Numbers
Given a two positive integers, s and p where s < p, write a program that
displays on the screen all positive even integers that lie in the range
of integers from the smaller to the larger. If one (or both) of the input
integers are also even, they must be included in the output.
Input:
The first line contains a positive integer n indicating how many
instances of the problem are subsequently described. Each such instance
is described on a single line by two numbers s and p.
Output:
For each instance of the problem given as input, the sequence
of even numbers lying between s and p as described above.
Sample input:
-----------2
2 20
13 41
IT Marathon Contest 2012
Resultant output:
---------------2 4 6 8 10 12 14 16 18 20
14 16 18 20 22 24 26 28 30 32 34 36 38 40
Programming
Page 6
Download