Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Maximum number of handshakes

It was Raj's first day at school. His teacher Anu asked the students to meet every other student in the class and to introduce themselves. The teacher asked them to do handshakes when they meet each other. If there are N number of students in the class then write a program to print the total number of handshakes made by the students.

Input

The first line is a single integer N

Output

Print the value representing total number of handshakes

Explanation

In the given example there are 5 persons. The first person shakes his hand with 4 persons. The second person then shakes his hand with 3 persons. The third person shakes his hand with 2 persons. The fourth person shakes his hand with 1 person.

From this, the number of handshakes = 4 + 3 + 2 + 1

So, the output should be 10

.



Leap Year

Write a program to determine whether the given year Y is a leap year or not. A normal year consists of 365 days. But the time required for Earth to revolve around the Sun is around 365.2425 days. So a "leap year" of 366 days is used once every four years to eliminate the error caused by three normal (but short) years. Any year that is divisible by 4 is usually a leap year: for example, 1988, 1992, and 1996 are leap years.

However, there is still a small error that must be accounted for. To eliminate this error, the calendar considers that a year that is divisible by 100 (for example, 1900) is a leap year only if it is also divisible by 400. For this reason, the following years are not leap years: 1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600, ... This is because they are divisible by 100 but not by 400.

The following years are leap years: 1600, 2000, 2400 This is because they are divisible by both 100 and 400.



Write a program that reads all the match outcomes and summarizes the information of all the matches. A win earns a team 3 points. The team information should be displayed in descending order of points.

Input1-The first line contains a single integer N, denoting the total no. of matches played.

The following N lines contain outcomes of N matches. The team name may contain spaces.

6

CSK;RR;loss

RR;DD;draw

MI;KKR;win

KKR;RR;loss

CSK;DD;draw

MI;DD;draw

Output1- If there are no teams to print in summary, print "No Output". Constraints

Names of teams may contain spaces but will be less than 24 characters 100 >= N >= 0.

Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0





Rearrange Numbers in String

Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.

Input
The input will be a single line containing a string.

Output
The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.

Explanation
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".

Sample Input

I am 5 years and 11 months old

Sample Output

I am 11 years and 5 months old

should pass all test cases i could able to do pass

Given a student has scored

M marks in Maths, P marks in Physics and C marks in Chemistry. Write a program to check if a student is eligible for admission in a professional course based on the following criteria:Sum of marks in any two subjects >= 100 and M + P + C >= 180.

Input

The first line is an integer

M, the second line is an integer P, and the third line is an integer C.Output

The output should be a single line containing

True if it satisfies the given conditions, False in all other cases.Explanation


Given

M = 82, P = 55, C = 45.


M + P >= 100,(137 >= 100)

M + C >= 100,(127 >= 100)

and, M + P + C >= 180 (82 + 55 + 45 >= 180)

 


So, the output should be

True.

Sample Input 1

82

55

45

Sample Output 1

True

Sample Input 2

71

30

70

Sample Output 2

False


Numbers in String - 2

Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters. Input-The input will be a single line containing a string. Output-The output should contain the sum and average of the numbers that appear in the string. Note: Round the average value to two decimal places.

input1-I am 25 years and 10 months old

output1-35
17.5

input2-1time3 %times4

output2-8
2.67

Numbers in String - 1

Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters. Input-The input will be a single line containing a string. Output-The output should contain the sum and average of the digits of all numbers that appear in the string.

Note: Round the average value to two decimal places.input1-I am 25 years and 10 months old

output1-8
2.0

input2-Anjali25 is python4 Expert

output2-11
3.67

Smallest Missing Number

Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers. Input-The input will be a single line containing numbers separated by space. Output-The output should be a single line containing the smallest missing number from given numbers.

input-1: 3 1 2 5 3 7 7

output-1:4

input-2: 5 5 2 3 1 8 8 4

output-2:6


Not getting proper output

Tic-Tac-Toe game


Abhinav and Anjali are playing the Tic-Tac-Toe game. Tic-Tac-Toe is a game played on a grid that's three squares by three squares. Abhinav is O, and Anjali is X. Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a diagonal or horizontal, or vertical row is the winner. When all nine squares are complete, the game is over. If no player has three marks in a row, the game ends in a tie. Write a program to decide the winner in the Tic Tac-Toe game.


Not getting output please send corrected output

Add two polynomials


Given two polynomials A and B, write a program that adds the given two polynomials A and B.


Input


The first line contains a single integer M. Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A. After that next line contains a single integer N. Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.


LATEST TUTORIALS
APPROVED BY CLIENTS