Solve as many problems as you can. Your time stamp will be recorded for each problem individually so send the solution as soon as possible. Best of Luck!!!
Wednesday, 5 March 2014
Problem 5
Aman is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows.
*If all the numbers are equal, the game ends.
Otherwise
*Select two numbers which are unequal
**Subtract the smaller number from the larger number
***Replace the larger number with the result from above (see the explanation section for clarity)
Aman has already figured out that the game always terminates. He also knows, for a given sequence of integers, the game will always terminate on the same value, no matter how the game is played. Aman wants you to simulate the game for him and tell him on which value will the game terminate for a given sequence of integers.
Output a single integer - the value of all the numbers when they are equal (and the game terminates), on a line by itself
Sample Case 1:
input(10,12)=2
Explanation:Since there are only two numbers, the operations are forced.
*{ 10, 12 } => Replace 12 with ( 12 - 10 = 2 ) => { 10, 2 }
*{ 10, 2 } => Replace 10 with ( 10 - 2 = 8 ) => { 8, 2 }
*{ 8, 2 } => Replace 8 with ( 8 - 2 = 6 ) => { 6, 2 }
*{ 6, 2 } => Replace 6 with ( 6 - 2 = 4 ) => { 4, 2 }
*{ 4, 2 } => Replace 4 with ( 4 - 2 = 2 ) => { 2, 2 }
Sample Case 2:
input(6,10,15)=1
*If all the numbers are equal, the game ends.
Otherwise
*Select two numbers which are unequal
**Subtract the smaller number from the larger number
***Replace the larger number with the result from above (see the explanation section for clarity)
Aman has already figured out that the game always terminates. He also knows, for a given sequence of integers, the game will always terminate on the same value, no matter how the game is played. Aman wants you to simulate the game for him and tell him on which value will the game terminate for a given sequence of integers.
Output a single integer - the value of all the numbers when they are equal (and the game terminates), on a line by itself
Sample Case 1:
input(10,12)=2
Explanation:Since there are only two numbers, the operations are forced.
*{ 10, 12 } => Replace 12 with ( 12 - 10 = 2 ) => { 10, 2 }
*{ 10, 2 } => Replace 10 with ( 10 - 2 = 8 ) => { 8, 2 }
*{ 8, 2 } => Replace 8 with ( 8 - 2 = 6 ) => { 6, 2 }
*{ 6, 2 } => Replace 6 with ( 6 - 2 = 4 ) => { 4, 2 }
*{ 4, 2 } => Replace 4 with ( 4 - 2 = 2 ) => { 2, 2 }
Sample Case 2:
input(6,10,15)=1
Problem 4
In this problem, you need to evaluate the expected value of the number of times we have non-zero carry when adding two non-negative integers that contain at most N digits each. Note that we are adding the numbers in their base 10 representation.
Sample Test Cases:
input(20,4)=0
input(111,119)=1
input(123,923)=1
input(1235,98765)=5
Sample Test Cases:
input(20,4)=0
input(111,119)=1
input(123,923)=1
input(1235,98765)=5
Problem 3
Given a line with W words separated by spaces. Reverse the order of words in the line.
Sample Input:
this is first input
Sample Output :
input first is this
Sample Input:
Aman
Sample Output :
Aman
Sample Input:
I Will be next DCL champ
Sample Output :
champ DCL next be Will I
Sample Input:
this is first input
Sample Output :
input first is this
Sample Input:
Aman
Sample Output :
Aman
Sample Input:
I Will be next DCL champ
Sample Output :
champ DCL next be Will I
Problem 2
Tom needs to make a rectangular box for his physics class project. He has bought P cm of wire and S (cm*cm) of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box.
Print a real number that is the largest volume of the box that Tom can make, rounded to two decimal places.
Sample Input 1:
20 14
Sample Output 1:
3.00
Output details: the dimensions of the largest box may be 3, 1 and 1.
Sample Input 1:
20 16
Sample Output 2:
4.15
Output details: the dimensions of the largest box may be 7/3, 4/3 and 4/3.
Problem 1
Round 3 starts tonight.
5 problems will be uploaded tonight. You have till 9 p.m on 6th March to solve these problems.
This round is open for everyone.
Here's your first problem:
Input:
The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer t(i) each.
Output:
Write a single integer to output, denoting how many integers t(i) are divisible by k.
Example:
Input:
7 3
1
51
966369
7
9
999996
11
Output:
4
5 problems will be uploaded tonight. You have till 9 p.m on 6th March to solve these problems.
This round is open for everyone.
Here's your first problem:
Input:
The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer t(i) each.
Output:
Write a single integer to output, denoting how many integers t(i) are divisible by k.
Example:
Input:
7 3
1
51
966369
7
9
999996
11
Output:
4
Round 3 for DCL....your FINAL chance !!
Round 3 for DAVIET Coding League will be help today.
This round is open for all and it is your final chance to make it to the finals. 5 questions will be posted today and 5 quickest contestants will be chosen for the final round !!
CODE! COMPILE ! CHEER!!
Stay tuned ...
This round is open for all and it is your final chance to make it to the finals. 5 questions will be posted today and 5 quickest contestants will be chosen for the final round !!
CODE! COMPILE ! CHEER!!
Stay tuned ...
Top 10 finalists from round 2
Greetings DCLites....
Great effort by all of you...
Here is the list of finalists from this round of coding league(ranks in order) :
1. Kartik Puri
2. Harkirat Singh
3. Arshpreet Singh Wadhera
4. Sukhraj Singh
5. Anjan Kaur
6. Rakshit Kuthiala
7. Naveen
8. Rishab Handa
9. Divyanshu Marwah
10. Sourav Sehgal
Final round for these top 10 will be held on 7th march at 10.30AM in lab 2.
for any queries contact our team.
Great effort by all of you...
Here is the list of finalists from this round of coding league(ranks in order) :
1. Kartik Puri
2. Harkirat Singh
3. Arshpreet Singh Wadhera
4. Sukhraj Singh
5. Anjan Kaur
6. Rakshit Kuthiala
7. Naveen
8. Rishab Handa
9. Divyanshu Marwah
10. Sourav Sehgal
Final round for these top 10 will be held on 7th march at 10.30AM in lab 2.
for any queries contact our team.
Tuesday, 4 March 2014
Problem #9
Description :
Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n.
Input :
Input contain an integer n.
Output :
Output contains the required sum i.e LCM(1,n)+LCM(2,n) + .. + LCM(n,n).
Sample Input :
2
Sample Output :
4
Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n.
Input :
Input contain an integer n.
Output :
Output contains the required sum i.e LCM(1,n)+LCM(2,n) + .. + LCM(n,n).
Sample Input :
2
Sample Output :
4
Monday, 3 March 2014
Problem 8
Given a string, find the number of palindromic substring of the string whose length is a prime number. The string consists only of lower case English alphabet. These palindromes need not be distinct.
Note:
1. Palindrome is a string which when reversed is the same. e.g: nitin
2. 1 is not a prime number.
Sample Test Cases:
palindromicPrime ("abac")=1
Explanation: The palindromic substrings in the string are "a", "b", "a", "c" and "aba" but only "aba" is of prime length. So output is 1.
palindromicPrime ("ababac")=4
Explanation: The palindromic substrings in the string are "a", "b", "a", "b", "a", "c", "aba", "aba", "bab" and "ababa". The prime length palindromes are "aba", "aba", "bab" and "ababa". So output is 4. Here we take both "aba" and "aba" as two different palindromes.
Note:
1. Palindrome is a string which when reversed is the same. e.g: nitin
2. 1 is not a prime number.
Sample Test Cases:
palindromicPrime ("abac")=1
Explanation: The palindromic substrings in the string are "a", "b", "a", "c" and "aba" but only "aba" is of prime length. So output is 1.
palindromicPrime ("ababac")=4
Explanation: The palindromic substrings in the string are "a", "b", "a", "b", "a", "c", "aba", "aba", "bab" and "ababa". The prime length palindromes are "aba", "aba", "bab" and "ababa". So output is 4. Here we take both "aba" and "aba" as two different palindromes.
Sunday, 2 March 2014
PROBLEM #7
Read the
problem statement carefully.
Problem statement: One of the our DCL 2014 team’s member Aman
Sharma is interested in the girl
living in the building (girl’s hostel) opposite to his building (boy’s hostel).
Aman Sharma wants to talk that girl but there is network problem today. SO clearly
there is no source of communication (that is no mobile or internet). So Aman
Sharma use his 3rd standard project called “PLAY TELEPHONE” (shown
in the picture below) to communicate with girl.
Now
the other boys and girls also starts communicate with each other with this
method. As a result there is web of different strings or wires (as shown in
picture below) creating lots of disturbances in the signal. “THERE IS A DISTURBANCE IN THE SIGNAL IF TWO STRINGS
INTERSECT WITH EACH OTHER.”
You have been given the
“INTEGER” height of each end of string from bottom of two buildings. Now your
task is to find out the no of disturbances (that is no of intersections) in the
strings.
NOTE: one boy or girl is
communicating with only one person girl or boy respectively.
INPUT: line
1 contains an integer no ‘N’ denotes
the total no. of strings or total no. of play telephones.
Next ‘N’ lines contain two variables (Ai, bi) height of string or wire from bottom of girls & boys hostel’s building.
Next ‘N’ lines contain two variables (Ai, bi) height of string or wire from bottom of girls & boys hostel’s building.
OUTPUT: NO.
Of intersection points you see.
SAMPLE Case 1:-INPUT- 3
2
9
4 4
5 5
OUTPUT- 2
Explanation:
N=3, means there are three wires or string (see picture below). The next three
lines contain integer height of wire
from bottom of buildings. That means wire one has height 2 at one end 9 at
other end from the bottom. Similarly 2nd and 3rd wire has
height of 4 and 5 units respectively. In this case output is 2 as you in
picture that the two white circles
represent intersection or disturbance points.
Case 2:- INPUT-
2
6 6
2
2
OUTPUT- 0
Explanation – n=2;
A1=6, B1=6
A2=4,B2=4
SO NO intersection, output=0
BEST OF LUCK
CODE! COMPILE! CHEER!
CODE! COMPILE! CHEER!
Saturday, 1 March 2014
Problem 6
Suppose that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in {1,2,3,8,9,3,2,1} is length 3 (the (1,2,3) part). Display the size of the largest mirror section found in the given array.
Sample Test Cases:
maxMirror(1,2,3,8,9,3,2,1)=3
maxMirror(1,2,1,4)=3
maxMirror(7,1,2,9,7,2,1)=2
Sample Test Cases:
maxMirror(1,2,3,8,9,3,2,1)=3
maxMirror(1,2,1,4)=3
maxMirror(7,1,2,9,7,2,1)=2
Subscribe to:
Posts (Atom)


