You are on page 1of 33

MATLAB ONLINE CONTEST EEE DAY 2017 QUESTION PAPER

Problem A : DSP Lab


First of all no need to be scared seeing the word DSP :p We don't need to know
anything about DSP to solve this problem ( as a matter of fact the problem setter is
also a noob in DSP :| )
Our protagonist Mr. Motlob is having dsp lab this term. Like all other things he is
not interested in doing lab works even a bit. Being highly annoyed even his teacher
said " ? "
But surprisingly he managed to learn one thing in this lab. The stem() function. In
the past he used to like plot() a lot, but now all he does is uses the stem() function
all day.
(for those are new to stem() this functions simply plots the points without joining
them. This figure should clarify :
>> x=[1,2,3,4,5,6,7];
>> y=[3,4,2,0,6,1,9];

plot(x,y) stem(x,y)
)
Again our Mr. Motlob only uses two digits 0 and 1 (he says he loves binary
number system but haters say otherwise :p ) . After learning this stem() function he
plots different sequences of 1 and 0 all day long. He was happy, until very recently
he decided to count his plots. But soon it turned to be a very huge number. So he
decided to only plot some certain sequences.
Roughly speaking :
1 ) He will only plot sequences of total length "n"
2) The sequences will only contain "0" or/and "1"
3) He won't put more then "x" 0's on a row.
4) Similarly he won't put more then "y" 1's on a row.
So our problem is simple. Given values of n , x and y, determine the total number
of unique points.
For example a valid plot for n = 9 , x = 2 , y =2 is :
Task :
Complete the function template dsp(). Which takes 3 inputs n,x and y.
Constraints :
Subproblem 1: (10 % marks )
1<= n <= 10
0 <= x <= 10
0 <= y <= 10
Subproblem 2: (20 % marks )
1<= n <= 100
0 <= x <= 10
0 <= y <= 10
Subproblem 3: (30 % marks )
1<= n <= 1000
0 <= x <= 10
0 <= y <= 10
Subproblem 4 : (40 % marks )
1<= n <= 1000
0 <= x <= 100
0 <= y <= 100

If the number gets very large Mr. Motlob will flee in terror, so in that case to calm
him down please output the modulo of result by 10^9 + 7
Sample Input and Output:
Input
n=4
x=2
y=2
Output = 6

Explanation: For this example possible combinations are:


[ 0 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 1 , 1 , 0 , 0 ] , [ 0 ,0 , 1 , 1 ], [ 0 , 1 , 1 , 0 ] ,
[1,0,0,1]
Problem B: Pen Pineapple Apple Pen
Maybe our protagonist Mr. Motlob don't know math very well ( although he claims
otherwise ) , but for bragging he follows all mathematical meme pages on
facebook :p .Recently he saw this meme.
Seeing this meme he shared it immediately, but unfortunately a guy with poor
sense of humor commented there: "Can you actually solve this? XD"
Now our protagonist is at stake and he needs your help to maintain his reputation,
otherwise who knows he may leave earth and go to mars.
Your task is simple. You'll be given n*m equations each with a constant and n
distinct variables of degree m. For example for n = 3 and m =2 one equation may
be :
3 x^2 + 4 x + 2 y^2 + 3 y + 5 z^2 + 7 = 0
Given the system of equations all you have to do is to solve it.
Task :
Complete the function template penPineapple(). Which takes 4 inputs n,m , a
(n*m)*(n*m) coefficient matrix and a vector of constants of size n*m
Output the values of the n variables as a vector
Constraint :
Subproblem 1 : (10 % marks )
1 <= n <= 5
m=1
Subproblem 2 : (20 % marks )
1 <= n <= 5
1 <= m <= 3
Subproblem 3 : (30 % marks )
1 <= n <= 10
1 <= m <= 3
Subproblem 4 : (40 % marks )
1 <= n <= 10
1 <= m <= 10
Sample Input and Output :
n=2
m =2
Coefficient matrix = [ 2 3 4 5
1 2 3 4
9 6 7 5
0 1 4 2]
Constants = [ 62 , 48 , 81 , 31 ]

Output = [ 1 , 3 ]
Special Note : Those who read "meme" as not , will not be graded :p

Problem C: Exam Hall


By now we have a very clear idea about our protagonist Mr. Motlob. So it should
be of no surprise that he hardly studies for his exams. But unfortunately he has to
attend the exam anyway.
The exam system is surprisingly simple all the have to do is to answer True/ False
questions. If the answer is correct 1 point is awarded otherwise no mark is
deducted.
It needs no mention that our protagonist is the last student of the class :p Still who
knows how he became best buddies with the top student. They are so good friends
that the top student actually helps his friend Mr. Motlob in test. The scenario is as
follows (we sincerely hope our teachers don't see this :| ) :

1) Since in a class of n students Mr. Motlob is the last student and his friend is the
first student, there sits (n-2) students between them. His friend will pass the answer
to him via the intermediate students.
2) His friend is very loyal and he will always say the right answer to the next
student.
3) However the other students are kind of strange, they may pass the correct
answer or may pass the wrong answer :/ We can estimate the probability that the i
th student will pass the correct answer as pi
4) Finally Mr. Motlob will always believe what the next student says and so he will
answer that exactly.
Now after the exam, due to his strange classmates Mr. Motlob would like to know
his expected score.
Task :
Complete the function template testScore(). Which takes 4 inputs n - the number of
students , m the number of questions , a vector p of size n-2 , indicating the
probabilty that the (i+1) th student will tell the correct answer [ here nth student is
Mr. Motlob and 1st student is his friend ] , next another vector of length m gives us
the actual answers ( 0 for false and 1 for true )
Subproblem 1 : (10 % marks )
2 <= n <= 5
1 <= m <= 5
Subproblem 2 : (20 % marks )
2 <= n <= 1000
1 <= m <= 5
Subproblem 3 : (30 % marks )
2 <= n <= 100000
1 <= m <= 5
Subproblem 4 : (40 % marks )
2 <= n <= 100000
1 <= m <= 10000
Sample Input and Output:
Input 1 :
n=3
m=1
p = [ 0.5]
answer = [ 1 ]
Output 1 = 0.5

Input 2 :
n=3
m=2
p = [ 0.5]
answer = [ 1 , 1 ]
Output 2 = 1.0
Note : Relative error up to 10-6 will be ignored.

Problem D : Hall Canteen


We already know Mr. Motlob isn't interested in anything, but that rule has only one
exception :p Mr. Motlob loves to eat a lot :p So even after almost failing in his
exam he is in the hall canteen for a feast :p
Usually the canteen offers quite a good number of foods in a very affordable price,
so our protagoinst Mr. Motlob eats to his heart's content. However he doesn't like
to eat one food more than once. Also he loves some foods more than the others, so
we may define a happiness meter of Mr. Motlob associated with each food. Also
he can't buy all the foods because of his budget.
Given his budget Mr. Motlob wants to know the amount of maximum happiness he
can achieve.
Task :
Complete the function template hallCanteen(). Which takes 4 inputs n - the number
of dishes , m Mr. Motlob's budget , a vector p of size n indicating the price of
the i th dish and another vector h of size n indicating the amount of happiness of
the i th dish.
Output the amount of maximum happiness he can achieve.
Subproblem 1 : (10 % marks )
1 <= n <= 5
1 <= m <= 5
Subproblem 2 : (20 % marks )
1 <= n <= 10
1 <= m <= 5
Subproblem 3 : (30 % marks )
1 <= n <= 20
1 <= m <= 1000
1 <= pi <= 100
1 <= hi <= 100
Subproblem 4 : (40 % marks )
1 <= n <= 40
1 <= m <= 1000
1 <= pi <= 100
1 <= hi <= 100
Sample Input and Output:
Input 1 :
n= 3
m = 100
p = [ 10 10 10 ]
h=[135]
Output 1 = 9

Input 2 :
n= 3
m = 15
p = [ 10 10 10 ]
h=[135]
Output 2 = 5

Problem E Buet EEE Library


Buet EEE department has one of the best academic libraries of Bangladesh
Students can study a variety of books here. Moreover to further aid the students in
their studies the library allows the students to borrow a book for a while provided
that they return it without causing any harms . Note that a student may only
borrow one book at a time.
Like our department our library is also very systematic. Each book is assigned an
unique id number which is a positive integer (>0) . And what's even greater is that
you're assigned as the new librarian. Your job is simple ,
1) when someone borrows a book you just save the book id in a database.
2) when they return the book you again save the book id in the database.

You can't issue a book if it isn't already returned right ? So it is guaranteed that a
book will be returned before it is issued again .
Now after the month ends you go through the database record to see whether any
book hasn't been returned. From your experience you know that all the students
return their book, but a certain Mr. Motlob.
So if a book is missing you know for sure that it is the work of Mr. Motlob.
However like Schrodinger's Cat Mr. Motlob's behavior is also uncertain and
sometimes he returns his book as shocking it may be.
Now your job is to determine whether any book is missing or not.
INPUT :
Complete the function library() that takes 2 inputs ,N -> the number of database
entries of the month.
A vector d -> contains N positive integers di (1< i <N) the database entries (i.e.
book id) .
OUTPUT :
If any book is missing return it's id.
If no book is missing simply return "0"
It is granted that all but Mr. Motlob are law abiding students and they'll return their
book on time. So no more than one book can be missing .
Subproblems :
Subproblem 1 : (10 % marks)
N = 10
1 < di < 10 (only 10 books in library )
Subproblem 2 : (20 % marks)
N = 1000
1 < di < 1000 (only 1000 books in library )
Subproblem 3 : (30 % marks)
N = 100000
1 < di < 100000 (only 100000 books in library )
Subproblem 4 : ( 40 % marks )
N = 100000
1 < di < 1018 (1018 books in library )
Sample Input and Output:
Input 1 :
N=5
d=[1,2,3,2,1]
Output 1 = 3

Input 2 :
N=6
d = [ 1 , 2 ,3 , 3 , 2 , 1 ]
Output 2 = 0

Problem F : Product
( Just to let you this problem is nothing about Industrial Production dont worry)
Mr. Motlob was one day bragging that he can do multiplication very fast and
accurate. So his friends challenged him to do the following.
1) Mr. Motlob will be given an array of integers.
2) At any stage he will have to multiply a segment of the array.
3) The product may be very large. In such cases his friends thinks Mr. Motlob
is bluffing so they ask him to say the most significant digit of the entire
product.
Task :
Complete the function template Product (). Which takes 4 inputs n - the number of
elements in the array , m number of queries , a vector array of size n indicating
the i th element of array and a matrix query of size (m,2) denoting the (l,r) values
of each query.
Return a vector containing the first digit of product of each segments.

Subproblem 1 : (10 % marks)


1 <= n <= 5
1 <= m <= 5
1 <= array element <= 100000
1<= l <= r <= n
Subproblem 2 : (20 % marks)
1 <= n <= 10
1 <= m <= 5
1 <= array element <= 100000
1<= l <= r <= n
Subproblem 3 : (30 % marks)
1 <= n <= 1000
1 <= m <= 1000
1 <= array element <= 1000
1<= l <= r <= n
Subproblem 4 : (40 % marks)
1 <= n <= 100000
1 <= m <= 100000
1 <= array element <= 100000
1<= l <= r <= n
Sample Input and Output:
Input 1:
n = 5
m=3
array = [ 2 , 3 ,5 , 6 ,10 ]
query = [ 1 , 1
1,2
3,4]
Output 1 = [ 2 , 6 , 3 ]

Problem G : Lab Report


Mr. Motlob hates but has to complete and submit his lab report. For the report he
was typing some numbers ( may be related to the experiment or may be he was just
wasting his time). But after some time he was shocked that his space button is not
working anymore, as a result where he typed a sequence of number he can only see
a long continuous number
Mr. Motlob can give a list of the numbers he may have written. From that
information can you break down the long number as the original sequence he was
trying to type ?
Mr. Motlob also said he was going to sum up the numbers, so he requests you not
to give the sequence but to give the sum of it.
Task :
Complete the labReport() function that takes 4 inputs N length of the set of all
possible input values , Numbers the vector of all possible input values , M length
of the continuous input number , Input the input number itself represented as digit
after digit in a vector.
Constraints :
Subproblem 1 : (10 % marks)
1 <= N <= 1
1 <= M <= 10
1 <= Numbers element <= 10000
Subproblem 2 : (20 % marks)
1 <= N <= 5
1 <= M <= 10
1 <= Numbers element <= 10000
Subproblem 3 : (30 % marks)
1 <= N <= 1000
1 <= M <= 1000
1 <= Numbers element <= 10000
Subproblem 4 : (40 % marks)
1 <= N <= 100000
1 <= M <= 100000
1 <= Numbers element <= 10000
Sample Input and Output:
Input:
N = 3
Numbers = [ 1 ,2 ,33 ]
M=5
Input = [1,2,3,3,1]
Output = 37
Problem H : Buet Wifi
There is nothing that Mr. Motlob loves more than free things. Thats why when
Buet Introduced Free Wifi he decided not to pay for his internet anymore. But the
problem is that he lives quite far from the buet hall and we all know that the wifi
range wont extend that far.
To overcome this difficulty Mr. Motlob came up with a fantastic plan. He decided
to buy some more phones and he will place them between his home and buet , then
the first phone will receive buet wifi and transmit to the next phone via wifi
hotspot , the next phone will receive from that and transmit to the next glub glub
glub finally he will use the last phone to use free internet !! ( Please dont comment
that itd be cheaper to pay for the internet, because you know its Mr. Motlob ).
Now surprisingly he found there can be n safe positions in a line from his home to
buet where he can hide the phones ( we understand that he cant put the phone in
an open space otherwise itll be stolen). Among those places he placed m phones
be bought.
Everything was going on well until one day he realized that the positioning of the
phones does matter as he receives different quality of internet depending on the
position of the phones. He found out that the internet quality changes as the
following rule :
y = a e-bx
where, y is quality of internet from a distance of x , a and b are two constants.
For example if a = 100 and b = 0.1

From this figure you get the idea, ideally in buet the internet is of quality 1 , at a
distance 5 there was a phone and so the quality became 100 e-0.5 (anything can
happen in this world right ?) Next at a distance of 5 no other phones were placed.
Next at home he placed another phone where the internet quality is
100 e-0.5 * 100 e-1 .
Now he want to know how to position the phones optimally so that he may get the
maximum internet quality. He doesnt bother about the positioning all he cares is
about the internet quality at home.

Task :
Complete the buetWifi() function that takes 5 inputs n number of possible safe
places , m number of phones Mr. Motlob bought , Dist the vector representing the
distance of ith safe spot from buet ,a and b the two constants mentioned above.
Output the best quality internet he may get at his home.
Constraints :
Subproblem 1 : (10 % marks)
1 <= n <= 5
m=1
1 <= Dist element <= 10
a is a real number
b is a real number
Subproblem 2 : (20 % marks)
1 <= n <= 5
1 <= m <= 5
1 <= Dist element <= 10
a is a real number
b is a real number
Subproblem 3 : (30 % marks)
1 <= n <= 1000
1 <= m <= 100
1 <= Dist element <= 10
a is a real number
b is a real number
Subproblem 4 : (40 % marks)
1 <= N <= 100000
1 <= M <= 100000
1 <= Dist element <= 10
a is a real number
b is a real number
Sample Input and Output:
Input 1 :
N=3
M=3
Dist = [5,10,15 ]
a = 100
b = 0.1
Output 1: 2.231301601484299e+05

Input 2 :
N=3
M=2
Dist = [5,10,15 ]
a = 0.1
b=-1
Output 2: 3.059023205018258e-08
Note : Relative Error less than 10-6 will be ignored.

Problem I : Ek dhile koy pakhi


Mr. Motlob went to a game show where he stands in a specified position and there
are some toy birds scattered around him, he will get a prize if he can hit the
maximum number of birds in a single shot (airgun not shotgun) .
Mr. Motlob knows very well that to do so all he has to do is to shoot at all the birds
in a line. But the problem is that in real life things dont work so easily. Because
after each impact the bullet takes some damage and one time itll fade away.
Youre given the amount of damage the bullet can take , position of Mr. Motlob ,
position and inflicted damage of all the birds. Output the maximum number of bird
Mr. Motlob can hit.

Task :
Complete the pakhi() function. It takes 5 inputs B -> The amount of damage the
bullet can take , X - > x coordinate of Mr. Motlob , Y -> y coordinate of Mr.
Motlob , N number of birds and a Matrix Birds of size (N*3) -> x position , y
position and damage ith bird can inflict.
Constraints :
Subproblem 1 : (10 % marks)
1 <= N <= 10
1 <= B <= 1018
1 <= damage inflicted <= 1018
- 1000 <= coordinates <= 1000
Subproblem 2 : (20 % marks)
1 <= N <= 100
1 <= B <= 1018
1 <= damage inflicted <= 1018
- 1000 <= coordinates <= 1000
Subproblem 3 : (30 % marks)
1 <= N <= 1000
1 <= B <= 1018
1 <= damage inflicted <= 1018
- 1000 <= coordinates <= 1000
Subproblem 4 : (40 % marks)
1 <= N <= 100000
1 <= B <= 1018
1 <= damage inflicted <= 1018
- 1000 <= coordinates <= 1000
Sample Input and Output :
Input 1 : B=5
X=0
Y=0
N=4

Birds = [ 1 , 1 , 1
2 , 2 , 1
3 , 3 , 1
4 ,5 ,1 ]
Output = 3

Input 2 : B=5
X=0
Y=0
N=4
Birds = [ 1 , 1 , 10
2 , 2 , 1
3 , 3 , 1
4 , 5 , 1 ]
Output = 1

Problem J : Hacchoo
Due to season changing a lot of the students of Mr. Motlobs class is infected with
seasonal flue. Whats even worse is that they infect others by it too. In this classes
all the students sit side by side in row (quite a long bench it is! ) Initially maybe 3
or 4 or maybe more students are infected. After each second they say the magical
word Hacchoo and it will infect the two persons sitting next to them ( i.e. the
left one and the right one) . If they were previously infected it will have no affect
but otherwise they will be infected now.
When all the students of the class gets infected the class teacher dismisses the
class. Mr. Motlob wants to know when the class will be dismissed.
Task :
Complete the function hacchoo() it takes 2 inputs N-> Number of students , Class
-> a vector of size N which shows the initial condition if the ith student is infected
then the ith vector entry is 1 otherwise it 0.
Compute the time when the class will dismiss.
Constraints :
Subproblem 1 : (10 % marks)
1 <= n <= 10
Subproblem 2 : (20 % marks)
1 <= n <= 100
Subproblem 3 : (30 % marks)
1 <= n <= 1000
Subproblem 4 : (40 % marks)
1 <= N <= 100000
Sample Input and Output:
Input:
N=6
Class = [ 1 , 0 , 0 , 0 , 1 , 0 ]
Output = 2
Explanation :
Time = 0 -> Class = [ 1 , 0 , 0 , 0 , 1 , 0 ]
Time = 1 -> Class = [ 1 , 1 , 0 , 1 , 1 , 1 ]
Time = 2 -> Class = [ 1 , 1 , 1 , 1 , 1 , 1 ]

Problem K : No Name
For this problem Mr. Motlob wont tell you anything ( which you may already
realize from the problem name).
One day you say Mr. Motlob running a code and getting the following output.
Input -> Output
0 -> 0
1 -> 1
2 -> 1
3 -> 2
4 -> 1
5 -> 2
6 -> 2
7 -> 3
8 -> 1
9 -> 2
10 -> 2
11 -> 3
12 -> 2
13 -> 3
14 -> 3
15 -> 4

Task :
You have to complete the function noName() that takes only one input in and
return the corresponding output , as Mr. Motlob would generate from his code.
Constraints :
Subproblem 1 : (20 % marks)
1 <= in <= 15
Subproblem 2 : (80 % marks)
1<= in <= 1018
Sample Input and Output:

Input = 27

Output = 4
Problem L: Mr. Motlob and Friends

One day Mr. Motlob went to eat with 2 of his friends. Luckily you were one of
them, and the other one is so embarrassed right now he dont want to reveal his
name, so we will call him Fred.
Now as always Mr. Motlob forgot to bring his wallet. So it was decided that you
and Fred would pay for him. Note here that you and fred may both pay his money
or only one of you may pay his money.
Now Mr. Motlob gets pretty scared when it comes to counting big numbers. So to
keep him calm you and Fred told him a smaller normalized version of the payment.
For example if you paid 500 and Fred paid 400 you may represent that by 5 and 4
(or even 50 and 40). These small values make Mr. Motlob confident.
Now Mr. Motlob paid the remaining 300. It is obvious that you would receive 200
and Fred would receive 100. But Mr. Motlob thinks that you should get ( 5 / ( 5 + 4
) ) * 300 = 167.67 and Fred should receive (4/(5+4))*300 = 133.33.
But this calculation is wrong ( and also youre getting less than you should ) so you
complained Mr. Motlob. But unfortunately how much you try to make sense to
him, he doesnt believe you.
However Mr. Motlob says that he will only believe a computer, so your only hope
is that if you can manage write a code that would output the correct amount you
should receive.
Task :
complete friends() function which takes 3 inputs . A -> ratio of your payment , B -
> ratio of Freds payment , C -> The total money Mr. Motlob will return.
Output the correct amount of money you should receive.
Relative error upto 10-6 will be ignored.
Constraints :
Subproblem 1 : ( 10 % marks)
1 <= A <= 10
1 <= B <= 10
1 <= C <= 10

Subproblem 2 : ( 20 % marks)
1 <= A <= 100
1 <= B <= 100
1 <= C <= 100
Subproblem 3 : ( 30 % marks)
1 <= A <= 1000
1 <= B <= 1000
1 <= C <= 1000
Subproblem 4 : ( 40 % marks)
1 <= A <= 100000
1 <= B <= 100000
1 <= C <= 100000
Sample Input and Output :
Input 1 : A = 5
B=4
C = 300
Ouput 1 = 200

Input 2 : A = 6
B=3
C = 300
Ouput 2 = 300

Problem M: Gravity
Sometimes the philosopher inside Mr. Motlob arises. He was thinking about
gravity one day. Due to gravity a ball will roll down from an inclined surface,
unless it gets stuck somewhere.

Mr. Motlob believes from his philosophical insight that the ball of fig A and fig B
will drop down but for the case of fig C it will not.
So given the heights of the different segments of a surface can you determine
whether the ball would drop down or not ?
Task :
Complete the gravity() function that takes 2 input. N -> number of heights , Height
-> A vector of size N denoting the heights at different places.
If the ball falls down return 1 as output else return 0 as output.
Constraints :
Subproblem 1 : ( 10 % marks)
2 <= N <= 10
0 <= heights element <= 10000
Subproblem 2 : ( 20 % marks)
2 <= N <= 10
0 <= heights element <= 10000
Subproblem 3 : ( 30 % marks)
2 <= N <= 10
0 <= heights element <= 10000
Subproblem 4 : ( 40 % marks)
2 <= N <= 10
0 <= heights element <= 10000
Sample Input and Output:

Input 1 : N = 3
Height = [ 5 ,3 , 1 ]
Ouput 1 = 1

Input 2 : N = 3
Height = [ 5 ,3 , 5 ]
Ouput 2 = 0
Problem N: Not Every Hero Wears Cape

Mr. Motlob always wanted to be a hero. But he does not know how to fly like
Superman or he does not possess money, devices or the throat cancer(!!!!) like
Batman :P In the morning of his 18th birthday, he brought out a weighing machine
and found out his weight was over 50kg. So he decided to donate blood and turned
into a real life hero (kudos to this superhero). Our protagonist donates blood after
every 120 days. He does not waste a single day. He knows just 10minutes of his
life can add some years to another persons life.

You will be given the date of the18th birthday of this superhero and another date.
You have to tell how many times he has donated blood.

Task:

Complete the function template save_life=donate_blood(birthday, today). Here,


birthday is the date of 18th birthday and today is another date( it does not
necessarily mean today cannot be past or future :P ). Both of the date is a matrix in
the format [Date Month Year]. You have to return the number of life he has saved
in save_life variable.

Sample Input and Output:

Input 1:
birthday=[ 1 1 2017]
today=[10 5 2017 ]

Output 1 : 2

Input 2:

birthday=[ 1 1 2017]
today=[1 1 2018 ]

Output 2: 4
Problem O :DX Ball
Mr. Motlob loves gaming. He started playing dx ball. But our beloved protagonist
missed the ball every single time and became fed up with the game. He decided to
create his own version of dx ball. There are blocks which are destroyed by the ball.
The ball is reflected diagonally every time it hits the ball or the wall of the matrix.
And guess what? There is no chance of being eliminated as there is no way to fall
down through the bottom of the matrix. Rather it is reflected just like the walls or
blocks whenever it hits the bottom. Mr. Motlob just starts the game by moving the
ball to a certain point of the matrix. From there the ball starts to move diagonally
and just goes on and on and on. A small part of the matrix is given below to get
familiarize with the co-ordinate system.

(0,3) (1,3) (2,3) (3,3)


(0,2) (1,2) (2,2) (2,3)
(0,1) (1,1) (2,1) (3,1)
(0,0) (1,0) (2,0) (3,0)

He was very much satisfied with it. But as soon as he started playing the game, he
found out that he cannot hit some blocks at all. He started looking for the bug in
the game but instead he found a bed bug in his hostels bed :3

Task:
Complete the function template cannot_hit=dxball(n,positon,start). Here n is the
number of blocks, position is a n*2 matrix where every row indicates the position
of the blocks and start is the co-ordinate from where the ball starts. You have to
return the number of balls which can never be hit in the cannot_hit variable.

Subproblem 1 : ( 10 % marks )
1 <= n <= 5
Subproblem 2 : ( 20 % marks )
1<= n <= 1000
Subproblem 3 : ( 30 % marks )
1 <= n <= 10000
Subproblem 4 : ( 40 % marks )
1 <= n <= 100000
Sample Input and Output :
Input 1 :
n=3
position=[ 1 2; 3 4; 2 6]
start=[ 1 1]

Output 1: 1

Input 2 :
n=5
position=[ 1 2; 3 4; 2 6; 4 5; 1001, 10001]
start=[ 2017 2020]
Output 2: 3
Problem P : Counting Stars
Mr. Motlob loves to gaze at the sky at night when no one is around him. He forgets
everything while doing so. He loves to create various shapes with the stars. His
most favorite shape is the circle. This thoughtful guy finds the stars which are on
the same circle. Then he starts from a star and imagines a straight line with the
adjacent star of the circle. He continues to do so until he returns to the first star.
Then with his amazing brain and imagination, he measures the total angle of the
shape he has just created by joining the stars.
Task:
Complete the function template m=stars(n). Here n is the number of stars on the
same circle. You have to return m. Here m=total angle of the shape/180 degree.
Sample Input: n=4
Output: 2
Problem Q : Back Calculation
Mr. Motlob one day who knows how generated a plot. He loved that very much so
he took a screenshot of it:

A zoomed in view
An even zoomed in view:

Now he would like very much to determine the function that generates this graph.
Please help him.
Task :
Complete the approximate() function . Which will take x as input and return value
of function at point x.
Note : This is an approximation problem. We don't expect you to give the correct
answer. You'll be graded relatively how better you've done compared to others.
The error will be computed as = abs (your output real value) / real value .
Sample input and Output :
Input:
x = 0.05
Output = 106.8

You might also like