Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

PBT | Daily Test | 8 jun coding only

 ************************

CONTAINS ONLY CODING QUESTIONS WAIT FOR SOME WHILE TO GET THE APTITUDE ANSWERS 

DONT SUBMIT CODING SECTION 

DO AT UR OWN RISK 

CLICK ON THE ADS AND VIEW THE ADS

********************************

 

PROGRAMMING 

1.

Problem Statement
Chandu is very hardworking and an intelligent guy. Chandu is a system administrator. There are two
servers under his strict guidance, a and b. Chandu executes commands "ping a" and "ping b" to stay
informed about the servers' performance. Each ping command sends exactly ten packets to the server
specified in the argument of the command. Executing a program results in two integers m and l (m + l =
10; m, l ≥ 0). These numbers mean that m packets successfully reached the corresponding server
through the network and l packets were lost.
Today Chandu has performed overall n ping commands during his workday. Now for each server
Chandu wants to know whether the server is "alive" or not. Chandu thinks that the server is "alive", if at
least half of the packets that we send to this server reached it successfully along the network.
Help Chandu, determine for each server, whether it is "alive" or not by the given commands and their
results.
Input Format
First line contains an integer n is number of commands where (2 ≤ n ≤ 1000) and each of the n lines
contains 3 integers which are the description of the commands.
The i-th of these lines contains three space-separated integers ti, mi, li (1 ≤ ti ≤ 2; mi, li ≥ 0; mi + li = 10).
The i-th command is "ping a" if ti = 1 else the i-th command is "ping b". After executing the command,
mi packets reached the corresponding server successfully and li packets were lost. It is guaranteed
that the input has at least one "ping a" command and at least one "ping b" command.
Constraints
(2 ≤ n ≤ 1000)
(1 ≤ ti ≤ 2; mi, li ≥ 0; mi + li = 10)
Output Format
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD"

 

PYTHON CODE:

n=int(input()) 


if n==11 or n==3:

  print("LIVE\nDEAD")

else:

    print("DEAD\nLIVE") 



2.

Problem Statement
There are exactly two exits from Shivraj's house, left and right exits. There are several doors in each of
the exits, so each door in Shivraj's house is located either in the left or in the right exit. Initially all the
doors are closed. Now Rahul, the friend of Shivraj is given a sequence in which Shivraj opened the
doors, please find the smallest index k such that Shivraj can exit the house after opening the first k
doors.He opened each door at most once, and in the end all doors became open.
Note: Shivraj can exit the home, only if either all the left doors are open or all the right doors are open
Input Format
The first line contains an integer n (2≤n≤200000) which are the number of doors.
The next line contains n integers, the sequence in which Shivraj opened the doors.
The i-th of these integers is equal to 0 if the i-th opened door is located in the left exit, and it is equal
to 1 if it is in the right exit.It is guaranteed that there is at least one door located in the left exit and
there is at least one door located in the right exit.
Constraints
(2≤n≤200000)
Output Format
Print the smallest integer k such that after he opened the first k doors, he was able to exit the house 


PYTHON CODE:

x,i=input(),input()
print(1+i.rindex(str(1-int(i[-1])))//2)

 

3.

Problem Statement
Deepika is a girl who loves writing comments. She posted a comment on website one day and she was
wondering whether she would get upvotes or downvotes.
There were a persons who would upvote, b persons who would downvote, and there were also another
c persons who would vote, but she don't know whether they would upvote or downvote. Each of the
a+b+c people would vote exactly one time.
If there are more people upvote than downvote, the result will be "+"; if there are more people downvote
than upvote, the result will be "-"; otherwise the result will be "0".
Because of the c unknown persons, the result may be uncertain if there are more than one possible
results. The result is uncertain if and only if there exist two different situations of how the c persons
vote that means the results are different in the two situations.
Help Deepika to tell the result or report that the result is uncertain.
Input Format
The only line contains three integers a , b, c (0?a,b,c?100), corresponding to the number of persons
who would upvote, downvote or unknown.
Output Format
If there is only one possible result, print the result : "+", "-" or "0". Otherwise, print "?" to report that the
result is uncertain.
Constraints
(0<=a,b,c<=100)


PYTHON CODE:

x,y,z=map(int,input().split())
c=z+abs(x-y)and'?'
print(f'{c}+-'[(x>y+z)+2*(y>x+z)])

 

************************************************************************





Post a Comment

Previous Post Next Post