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

Triplet sum


Given an array n integers, find and print all the unique triplets (a,b,c) in the array which give the sum K.(a+b+c=K)


Input


The first line of the input will be space separated integers, denoting the elements of the array. The second line of the input will be an integer denoting the required sum K.


Output


The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print"No matching triplets found" if there are no triplets with the given sum.


Sample input


0 12 17 8 9 21


29


Sample output


(0, 8, 21)


(0, 12, 17)


(8, 9, 12)

Rotate matrix rings



Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don't rotate that ring.



Input:



The first line of input will be two space separated integers, denoting the M and N. The next M lines will contain N space separated integers. The next line will contain an integer, denoting K



Output:



The output should be M*N matrix by K elements.



Sample input:



3 4



1 2 3 4



10 11 12 5



9 8 7 6



2



Sample output:



9 10 1 2



8 11 12 3



7 6 5 4

Exam scores


Captain Holt has corrected the exam papers of detectives and noted the scores of the written and physical tests. The results were posted in two lists: one with the scores of the written test, the other with the scores of the physical test in order of the badge numbers. The office needs a list containing the detectives scores on both tests in order of their badge numbers.


Input:


First line of input contains the score of students in chemistry exam seperated by comma.


Second line of the input contains the score of students in English exam seperated by comma.


Output:


Every line of output contains the score obtained by each student in English and Chemistry exams separated by space.


Sample input:


65


75


Sample output:


75 65


Sample input:


85,88,78


85,86,84


Sample output:


85 85


86 88


84 78

Unique Matrix


You are given a N*N matrix. write a program to check if the matrix is unique or not. A unique Matrix is a matrix if every row and column of the matrix contains all the integers from 1 to N


Input:


The first line contains an integer N.


The next N lines contains N space separated values of the matrix.


Output:


The output contains a single line and should be True if the matrix is unique matrix and False otherwise.


Sample input:


4


1 2 3 4


2 3 4 1


3 4 1 2


4 1 2 3


Sample output:


True



Maximum number of books:


There are multiple (T) book stores 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


Input:


The first line of input is a positive integer T that represents the number of shops.The following lines represent the details of the T shops. Each set of two consecutive lines represent the details of a shop. The first line of each set contains two space separated integers B and P. The second line of each set contains B space separated integers.


Output:


The output should be T lines. Each line contains an integer that represents the maximum number of books that can be bought in each shop.

A Game of Patterns



A teacher asked Ramesh to draw a Quadrilateral of a specific pattern with only symbol. The length and height should be L. Here L is the number of characters in every line. The height of the



*



quadrilateral is the number of lines it contains.



The slope of the quadrilateral taken as S represents the the number of extra space characters in a line when compared to its next line.



The last line will not have any space characters before the



character.

Temperature Conversion

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places.


Input

The first line of the input contain a temperature Value in one of Celsius, Fahrenheit, and Kelvin scales.


Output

first output should contain the Celsius value and the unit of the Celsius without any space.

second l output should contain the Fahrenheit value and the unit of the Fahrenheit without any space.

third output should contain the Kelvin value and the unit of the Kelvin without any space.

For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.

imp: here ouput gives 289.1k instead of 289.0k why ?



Find latitude and longitude of utmost 20 countries, ordered by population, with a population greater or equal to the population limit given below and have atleast one currency exclusively for themselves. (countries like Madagascar, Sri Lanka but not India, USA). Use the country details from this dataset.

Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.

Assume radius of earth: 6371 km

Round length of each line and final result to 2 decimal points

If co-ordinates are missing for any country use 0.000 N 0.000 E


Population limit: 65110000

Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit before submitting.


1000 : 8

500 : 1

100 : 0

50 : 1

20 : 2

5 : 0

1 : 3


how to remove spaces before and after :

denominatio problem


Input 10 numbers. Put it in a list. Turn every item of a list into its square. Print the result.


Expected output:

Enter Input 1

Enter Input 2

Enter Input 3

Enter Input 4

Enter Input 5

Enter Input 6

Enter Input 7

Enter Input 8

Enter Input 9

[1, 4, 9, 16, 25, 36, 49, 64, 81]

Note: the inputs are used for demonstration purposes only. Use yor own combination of inputs.