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

Friend and Enemy

A group of F friends went to a haunted house.Each member was given a shirt with a number on it ranging from 1 to F. As they entered the haunted house, one of them was kidnapped and an enemy joined them.But unfortunately, the enemy didn't wear the shirt with the same number as the kidnapped one, instead wore the same as some other person.Find the numbers on the shirts of the enemy and the kidnapped person.


Input

The input is a single line containing space-separated positive integers from 1 to F.


Output

The output should be a single line containing the shirt numbers of the enemy and kidnapped person separated by a space.


Explanation

The given array is 3 1 5 2 1.

In the range from 1 to 5, the number 1 has occured twice and 4 is the missing number. So, 1 belongs to the enemy's shirt, and 4 belongs to kidnapped.Hence, the output should be 1 4.


Sample Input1

3 1 5 2 1

Sample Output1

1 4


Sample Input2

1 2 2 4

Sample Output2

2 3


Repeated Numbers

Eren wants to decode a number.After lots of trial and error, he finally figured out that the number is a count of repeated single-digit integers.

Write a program to help Eren print the decoded number given a string of integers N.


Input

The first line contains a string of integers N.


Output

The output contains a single integer representing count of repeated numbers in the input.


Explanation

For N = 212311 ,

1 and 2 are repeated.Therefore, the output is 2.


Sample Input1

212311

Sample Output1

2


Sample Input2

111

Sample Output2

1


Maximum Number of Books

There are multiple (T) bookstores in the area.Each shopkeeper has a list of B integers that represents the cost of each book.You have different pocket money(P) for each bookstore.Write a program to calculate the maximum number of books you can buy in each store with the corresponding pocket money.


Explanation

Given P = 600 and B = [120, 140, 110, 180, 120, 110] with a pocket money of 600, we can buy the books at index 0,1,2,4,5 , whose sum is 120+140+110+120+110 is equal to P.

Given P = 300 and B = [120 110 1300 130] with a pocket money of 300, we can buy the books at index 0,1 whose sum is 120 + 110 and is less than P.

Given P = 100 and B = [220 1000 500 2000] with pocket money of 100, we can't buy any book. So the output should be Retry.



Sample Input1

3

6 100

20 40 10 80 20 10

4 70

20 10 300 30

4 200

220 1000 500 2000


Sample Output1

5

3



Sample Input2

2

8 250

2070 1350 365 2750 30 20 140 240

4 500

1070 2893 2200 39


Sample Output2

3

1







A basket contains of three fruits has to be created using apples and mangoes



Saurabh believes that the optimal fruit basket of three fruits should



consist of one


Apple and two mangoes. Adish believes that the two apples and one mango. fruit basket should have





There are A apples and B mangoes. Can you calculate what maximum number of imar.chine baskets that can be formed?



Input Format



The first line contains an integer, A, denoting the number of apples.





The next line contains an integer, B, denoting the the number of mangoes.



constrants



1 <=A<= 10^5



1 <= B <= 10^5



Sample





1



2



1









Sample Output








are only 2 fruits in total, hence no optimalees baskets can be



Only one optimal basket can be made be (A, M, M), where A represents an Apple, and M represents a Mango. niteeshkuma



3 optimal fruit baskets can be made i.e (A, M. M) (A, M, M), (A, A, M). where A represents an Apple, and M represents a Mango itees




1.Same program as addition teaching program

2.But the student must get three questions correctly in a row to pass the test.

3.If the student get 1 question wrong, the counter will be reset to zero.


Code:

import random


print("Welcome to New Academy:")

print("It is a mathematic test. You have to answer 5 questions.")

print("You need to answer 3 questions correctly to pass the test.")

print("If you failed, you need to repeat the test.")


# setup the stop conditions for the program

# generate 5 addition questions

# before that, generate 2 numbers randomly

# compute the summation of the 2 numbers and store it in a variable

# Track how many questions were answered correctly by the student

# if the student got 3 questions and above correctly, 

# congratulate the student and stop the program

# else, repeat the test.


1.Create a program to test the addition (+) skill of students. (0 – 100)

2.The program can automatically generate 5 questions for a student to answer.

3.A student must correct at least 3 questions to pass the test. 

4.If the student failed, he needs to repeat the test.


Code:

import random


print("Welcome to New Academy:")

print("It is a mathematic test. You have to answer 5 questions.")

print("You need to answer 3 questions correctly in a row to pass the test.")


1.Count how many vowels (a, e, I, o, u) in a word.


Code:

import random

import string


word = ""

for i in range(20):

  word += random.choice(string.ascii_lowercase)


print(word)

# write your code here


Can you use if statements or while loops within a function? Illustrate with an example.


Your given with N number of coordinates and you have to create a polygon such that they will make a polygon with maximum area


What is a module namespace? How is it useful?


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS