Infytq Coding Questions Set 1.pdf

  • Uploaded by: Walker Sanket
  • 0
  • 0
  • January 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Infytq Coding Questions Set 1.pdf as PDF for free.

More details

  • Words: 3,202
  • Pages: 39
Loading documents preview...
1) Given a number N, check if a number is perfect or not. A number is said to be perfect if the sum of all its factors excluding the number itself is equal to the number. Input Format First-line consists of T test cases. Then T test cases follow. Each test case consists of a number N. Output Format For each test case, in a new line, output in a single line 1 if a number is a perfect number else print 0. Constraints 1<=T <= 300 1<=N<=1018 Sample Testcases Testcase 1 Input Testcase 1 Output 2 6 21

1 0

Video Solution Link: https://www.youtube.com/watch?v=UbYooq6bHjc&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

2) AES Numbers Varun is the founder of Event Management Company, “Sparsh Services’. In the company, all the financial transactions are carried out online and Varun has strictly insisted his staff do any transactions on web browsers that support AES encryption numbers. A number is an AES number if it has exactly four divisors. In other words, there are exactly four numbers that divide into it evenly. For example, 10 is an AES number because it has exactly four divisors (1, 2, 5, 10). 12 is not an AES number because it has too many divisors (1, 2, 3, 4, 6, 12). 11 is not an AES number either. There is only one AES number in the range 10...12. Given a range of numbers, write a program that counts how many numbers from that range are AES numbers. input Format The input consists of 2 space-separated integers, which corresponds to the lower limit and the upper limit of the number range. You may assume that the numbers in the range are less than 1000.

Output Format Output a single line that gives the count of AES numbers from the given range. Refer to sample input and output for formatting specifications. Sample Testcases Testcase 1 Input Testcase 1 Output 1 20 5 Testcase 2 Input 50 100

Testcase 2 Output 17

Video Solution Link: https://www.youtube.com/watch?v=dzYBHGbanJs&feature=youtu.be

3) Daily Routine Brendon is a little techno-whiz whose IQ is out of the charts. He has set up a laboratory at home for his research and development and was once approached by an Event Management firm to design them a Robot that would log all the activities carried out in an event at various instants during the day. This would help them keep a track and in the smooth functioning of events. Brendon, after long days of hard work, designed one such Robot but wanted to test it on his own daily routines. His daily routine is very simple, he starts his day working in a computer, then he eats food and finally proceeds for sleeping(in the same order) thus ending his day. He has programmed his Robot to log the activities of him at various instants during the day. Today it recorded activities that Brendon was doing at N different instants. These instances are recorded in chronological order (in increasing order of time). This log is provided to you in form of a string s of length N, consisting of characters ‘C’, 'E’ and ‘S’. If s[i] = ‘C’, then it means that at the i-th instant Brendon was working in Computer, 'E' denoting he was eating and 'S' means he was sleeping. Write a program to tell whether the record log made by the robot could possibly be correct or not.

Input Format The only line of input contains the string s. Output Format Output a single line containing "yes" or ‘no’ (without quotes) accordingly. Refer to sample input and output for formatting specifications. Sample Testcases Testcase 1 Input CES Testcase 2 Input SCCC

Testcase 1 Output yes Testcase 2 Output no

Video Solution Link: https://www.youtube.com/watch?v=SHl0Vv6E350&feature=youtu.be

4) Series 2 The Event Organizing Company "Buzzcraft" focuses on event management in a way that creates a win-win situation for all involved stakeholders. Buzzcraft doesn't look at building one time associations with clients, instead, aim at creating long-lasting collaborations that will span years to come. This goal of the company has helped them evolve and expand big with more workforces within notable times. The number of employees of the company from the start day of their journey till now is recorded sensibly and is seemed to have followed a specific series like: 20, 60, 104, 152, 204,....... Write a program which takes an integer N as the input and will output the series till the Nth term. Input Format First line of the input is an integer N. Output Format Output a single line the series till Nth term, each separated by a comma. Refer to sample input and output for formatting specifications.

Sample Testcases Testcase 1 Input 5

Testcase 1 Output 20 60 104 152 204

Testcase 2 Input

Testcase 2 Output

10

20 60 104 152 204 260 320 384 452 524

Video Solution Link: https://www.youtube.com/watch?v=D12IpFww54A&feature=youtu.be

5) Team Event Super Quiz Bee is a famous quiz Competition that tests students on a wide variety of academic subjects. This week's competition was a Team event and students who register for the event will be given a unique registration code N. The participants are teamed into 10 teams and the team to which a participant is assigned to depends on the absolute difference between the first and last digit in the registration code. The event organizers wanted your help in writing an automated program that will ease their job of assigning teams to the participants. If the registration number given is less than 10, then the program should display “Invalid Input’. Input Format The only line of input contains an integer N. Output Format Output the absolute difference between the first and last digit of N. Refer to sample input and output for formatting specifications.

Sample Testcases Testcase 1 Input 345 Testcase 2 Input 9

Testcase 1 Output 2 Testcase 2 Output Invalid Input

Video Solution Link: https://www.youtube.com/watch?v=EbboC6cTz_k&feature=youtu.be

6) Triangle Game The Westland Game Fair is the premier event of its kind for kids interested in some intellectual and cognitive brain games. Exciting games were organized for kids between the ages group of 8 and 10. One such game was called the “Triangle game", where different numbers of boards in the range 1 to 180 are available. Each kid needs to select three number boards, where the numbers on the boards correspond to the angles of a triangle. If the angles selected by a kid form a triangle, he/she would receive Prize 1. If the angles selected by a kid form a right triangle, he/she would receive Prize 2. If the angles selected by the kids form an equilateral triangle, he/she would receive Prize 3. If the angles selected by a kid do not form even a triangle, then he/she will not receive any prizes. Write a program for the organizers to fetch the result based on the number of boards selected by the kids. Input Format There are 3 lines in the input, each of which corresponds to the numbers on the boards that the kids select.

Output Format Output should display “Prize 1° or “Prize 2” or "Prize 3° or "No Prize” based on the conditions given. Refer to sample input and output for formatting specifications. Sample Testcases Testcase 1 Input Testcase 1 Output 60 Prize 1 50 70 Testcase 2 Input 60 60 70

Testcase 2 Output No Prize

Video Solution Link: https://www.youtube.com/watch?v=h2fQTjVm0b0&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

7) Given a set of numbers of length N. Your task is to find the quad set (x1,x2,x3,x4) which will result the sum as 1. If such quad set exists print YES else print NO Input Format First-line contains a number of integers N Second-line contains space-separated N integers Output Format Displays 'YES' if summation of quad set is 1 at least for one combination. Otherwise displays 'NO' if summation of quad set is not equal to 1 for any of the combinations. Constraints N>3 Sample Testcases Testcase 1 Input Testcase 1 Output 6

YES

2 -1 0 0 1 0 Testcase 2 Input

Testcase 2 Output

5

NO

12342

Video Solution Link: https://www.youtube.com/watch?v=WoE5I72FCAk&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

8) In an exam, Regina has to find the smallest exact divisor of a number other than one. Write a program to obtain a number and to find the smallest exact divisor of a number other than 1. Input Format Input consists of a single number. Output Format Output consists of a single number which is the smallest exact divisor of the number other than 1. Sample Testcases Testcase 1 Input Testcase 1 Output 55 5 Testcase 2 Input 39

Testcase 2 Output 3

Video Solution Link: https://www.youtube.com/watch?v=ZKd_lSqkgA8&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

9) Nth Fibonacci The Fibonacci sequence is defined as follows: the first number of the sequence is 0, the second number is 1, and the nth number is the sum of the (n-1)th and (n-2)th numbers. Write a program that takes in an integer n and print the nth Fibonacci number Input Format An integer in the first line Output Format Nth Fibonacci element Sample Testcases Testcase 1 input Testcase 1 Output 8

13

Video Solution Link: https://www.youtube.com/watch?v=dBMP-Prxd_U&feature=youtu.be

10) There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: 1. Each child must have at least one candy. 2. Children with higher rating get more candies than the children with lower rating What is the minimum candies you must give? Input Format First-line of input contains the number of children N. Second-line contains N integers separated by spaces represents the rating Output Format Output displays an integer representing the number of candies Constraints Input Size : N<=100000 Sample Testcases Testcase 1 Input Testcase 1 Output 5 7 12121

Testcase 2 Input 5 53613

Testcase 2 Output 12

Video Solution Link: https://www.youtube.com/watch?v=jy80b_OUfYU&feature=youtu.be

11) WonderWorks Magic Show The Magic Castle, the home of the Academy of Magical Arts at California has organized the great ‘WonderWorks Magic Show’. 3 renowned magicians were invited ta mystify and thrill the crowd with their world’s spectacular magic tricks. At the end of each of the 3 magicians’ shows, the audience were requested to give their feedback in a scale of 1 to 10. Number of people who watched each show and the average feedback rating of each show is known. Write a program to find the average feedback rating of the Wonder Works Magic show. Input Format First line of the input is an integer value that corresponds to the number of people who watched show 1. Second line of the input is a float value that corresponds to the average rating of show 1. Third line of the input is an integer value that corresponds to the number of people who watched show 2. Fourth line of the input is a float value that corresponds to the average rating of show 2. Fifth line of the input is an integer value that corresponds to the number of

people who watched show 3. Sixth line of the input is a float value that corresponds to the average rating of show 3. Output Format Output should display the overall average rating for the show. Display the rating correct to 2 decimal places. (Use the key word round to round off the decimal places). Refer sample input and output for formatting specifications. Constraints 0<=Average rating <=10 Sample Testcases Testcase 1 input Testcase 1 Output 400 9.22 9.8 500 9.6 100 5

Video Solution Link: https://www.youtube.com/watch?v=xiED7TPu1lQ&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

12) Birthday Challenge Louis was celebrating his 10th Birthday and his parents wished to make his birthday more special by throwing a surprise bash, inviting all their friends, relatives and neighbours. The little mathematics geek Louis has another surprise waiting for him when he had to cut his favourite Choco vanilla cake. The cake is a rectangular cake and it consists of mxn (1Sm, nS1000) squares. His friends now called him out for a challenge. The challenge is that Louis has to break the cake up into 1x1 pieces (individual squares) and find what is the minimum number of times that he breaks the Choco vanilla cake, or pieces thereof, in order to achieve this? Note that he cannot stack pieces of the cake and break them because the choco vanilla cake is thick. As an example, a 2x2 cake requires 3 breaks. Firat he can break it in half, then break each of the halve in half. He cannot break it in half, stack the two 1x2 pieces, and then use only one more break to achieve his goal. Input Format First line of the input consists of an integer, the dimensions m of the choco vanilla cake. Second line of the input consists of an integer. the dimensions n of the choco vanilla cake.

Output Format Output the minimum number of times that he breaks the Choco vanilla cake Sample Testcases Testcase 1 Input Testcase 1 Output 3 2 2 Testcase 2 input 1 2

Testcase 2 Output 1

Video Solution Link: https://www.youtube.com/watch?v=DMsE7tXfVq8&feature=youtu.be

13) CALCULATING GAIN PERCENTAGE Vikram buys an old scooter for Rs. A and spends Rs. 8 on its repairs. If he sells the scooter for Rs. C . what is his gain %? Write a program to compute the gain %. Input Format The first input is an integer which corresponds to Cost price. The second input is an integer which corresponds to repair cost. The third input corresponds to the Selling price. Output Format Refer to sample input and output for formatting specifications. The float values are displayed correctly to 2 decimal places. Sample Testcases Testcase 1 Input Testcase 1 Output 4700 5.45 800 5800

Video Solution Link: https://www.youtube.com/watch?v=lpBM8gbIBrY&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

14) Food Festival at HillTown Hill Town Inn is planning to organize a Food Festival bringing together at one place, a wide variety of cuisines from across the world on account of Christmas. The Hotel Management has rented out a square hall of an indoor Auditorium for this extravaganza. The side of the square hall is y inches in which a large square table is placed for the display of the most popular and celebrated food items. The side of the square table is x inches, such that x
Sample Testcases Testcase 1 Input 7 3 Testcase 2 Input 5 2

Testcase 1 Output 40 Testcase 2 Output 21

Video Solution Link: https://www.youtube.com/watch?v=oTj9mm28bbk&feature=youtu.be

15) Bala distributes C chocolates to school N students every Friday. The C chocolate are distributed among N students equally and the remaining chocolates R are given back to Bala As an example, if C=100 and N=40, each student receives 2 chocolates and the balance 100-40*2=20 is given back Input Format The first line denotes C The second line denotes N Output Format The first line denotes R-the number of chocolate to be given back Sample Testcases Testcase 1 Input Testcase 1 Output 300 30 45

Video Solution Link: https://www.youtube.com/watch?v=gIsjyUB4wDM&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

16) Write a program to print the sum of the first K natural numbers. Input Format Input consists of an Integer K. Output Format Output the sum of first k natural numbers. Sample Testcases Testcase 1 Input Testcase 1 Output 5

15

Video Solution Link: https://www.youtube.com/watch?v=lX31-GipvyE&feature=youtu.be

17) Raju borrowed Rs. 20000 from Ramu at an interest rate of 5%. Write a program to find the simple interest for 5 units of time. ( Simple interest is given by: SI = (P*T*R)/100 where P is the principle amount, T is the time, R is the rate). Input Format Input is directly given in the program Output Format Output is the number representing a simple interest Sample Testcases Testcase 1 input

Testcase 1 Output 5000.0

Video Solution Link: https://www.youtube.com/watch?v=HrtPf46rC2U&feature=youtu.be

18) On looking at a two-dimensional array, Samir can find out the number of perfect squares among the array elements. Help him write a computer program that does the same operation. Input Format First-line consists of the rows and columns to be present in the array; The elements of the array are given in the consecutive lines representing an r x c matrix. Output Format Output is displayed as shown in the sample test cases according to the scenario. Constraints Maximum number of rows and columns = 10 Sample Testcases Testcase 1 Input Testcase 1 Output 33 2 Perfect Squares. 56 -8 5 -6 8 9 7 4 19

Testcase 2 Input -8 -6

Testcase 2 Output Invalid Rows or columns

Testcase 3 Input 16 8 5 19 24 53 78

Testcase 3 Output No Perfect Squares.

Video Solution Link: https://www.youtube.com/watch?v=e7gho28AqUU&feature=youtu.be

19) During class, the teacher asks the students to come in roll number order and give a complex programming question to other students. Aravind comes first and gives a question to find the second largest number in a set of elements without using array. Input Format The first line of the input consists of the value of n. The next n lines consists of n elements. Output Format The output prints the second largest element. Sample Testcases Testcase 1 Input Testcase 1 Output 10 856 752 963 741 523 983 785 866 529 122

963

Video Solution Link: https://www.youtube.com/watch?v=tW9IIfkysao&feature=youtu.be

20) Write a program that prints the numbers in a right-angled triangle in such a way that the row number represents the value and the count of the number. Input Format Input consists of a single integer Output Format Output is displayed as shown in sample test case Constraints O
Testcase 2 Output Invalid

Video Solution Link: https://www.youtube.com/watch?v=S5otaPRlzhs&feature=youtu.be

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video

Related Documents


More Documents from "api-26304852"