6. Whole Minute Dilemma A music player allows users to choose songs to play, but only...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
6. Whole Minute Dilemma A music player allows users to choose songs to play, but only in pairs and only pairs of songs with durations that add up to a multiple of 60 seconds (e.g., 60, 120, 180). Given a list of song durations, calculate the total number of different song pairs that can be chosen. Example n = 3 songs = [40, 20, 60] One pair of songs can be chosen whose combined duration is a multiple of a whole minute (40 + 20 = 60) and the return value would be 1. While the third song is a single minute long, songs must be chosen in pairs. Function Description Complete the function playlist in the editor below. playlist has the following parameter(s): int songs[n]: array of integers representing song durations in seconds Returns: int: the number of songs pairs that add up to a multiple of a minute Constraints • 1 ≤n≤ 105 1 ≤ songs[i] ≤ 1000, where 0 si<n ● Python 3 1 >#!/bin/python3... 10 11 12 13 14 15 16 17 18 19 20 21 > V # # Complete the 'playlist' function below. # > if ● Autocomplete Ready O # The function is expected to return a LONG_INTEGER. # The function accepts INTEGER_ARRAY songs as parameter. # def playlist (songs): name # Write your code here == '__main__':- 1.... I ▾ Input Format For Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer, n, that denotes the number of elements in songs. The next n lines each contain an integer that describes songs[i] and denotes the duration of the ¡th song in seconds. ▾ Sample Case 0 Sample Input For Custom Testing STDIN 4 10 50 90 30 2 → Sample Output Function STDIN songs [] size n = 4 songs [10, 50, 90, 30] Explanation The first and second songs pair to 60 seconds. The third and fourth songs pair to 120 seconds. No other pairs will satisfy the requirement. 5 ✓ Sample Case 1 Sample Input For Custom Testing Function songs [] size n = 5 [30 20. 150. 100, 40] Python 3 1> #!/bin/python3... DH234STON 10 11 12 13 16 14 # The function is expected to return a LONG_INTEGER. 15 # The function accepts INTEGER ARRAY songs as parameter. # 17 18 19 # # Complete the 'playlist' function below. # Autocomplete Ready Ⓒ def playlist (songs): # Write your code here 20 21 > if __name___ Test Results I main Custom Input 6. Whole Minute Dilemma A music player allows users to choose songs to play, but only in pairs and only pairs of songs with durations that add up to a multiple of 60 seconds (e.g., 60, 120, 180). Given a list of song durations, calculate the total number of different song pairs that can be chosen. Example n = 3 songs = [40, 20, 60] One pair of songs can be chosen whose combined duration is a multiple of a whole minute (40 + 20 = 60) and the return value would be 1. While the third song is a single minute long, songs must be chosen in pairs. Function Description Complete the function playlist in the editor below. playlist has the following parameter(s): int songs[n]: array of integers representing song durations in seconds Returns: int: the number of songs pairs that add up to a multiple of a minute Constraints • 1 ≤n≤ 105 1 ≤ songs[i] ≤ 1000, where 0 si<n ● Python 3 1 >#!/bin/python3... 10 11 12 13 14 15 16 17 18 19 20 21 > V # # Complete the 'playlist' function below. # > if ● Autocomplete Ready O # The function is expected to return a LONG_INTEGER. # The function accepts INTEGER_ARRAY songs as parameter. # def playlist (songs): name # Write your code here == '__main__':- 1.... I ▾ Input Format For Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer, n, that denotes the number of elements in songs. The next n lines each contain an integer that describes songs[i] and denotes the duration of the ¡th song in seconds. ▾ Sample Case 0 Sample Input For Custom Testing STDIN 4 10 50 90 30 2 → Sample Output Function STDIN songs [] size n = 4 songs [10, 50, 90, 30] Explanation The first and second songs pair to 60 seconds. The third and fourth songs pair to 120 seconds. No other pairs will satisfy the requirement. 5 ✓ Sample Case 1 Sample Input For Custom Testing Function songs [] size n = 5 [30 20. 150. 100, 40] Python 3 1> #!/bin/python3... DH234STON 10 11 12 13 16 14 # The function is expected to return a LONG_INTEGER. 15 # The function accepts INTEGER ARRAY songs as parameter. # 17 18 19 # # Complete the 'playlist' function below. # Autocomplete Ready Ⓒ def playlist (songs): # Write your code here 20 21 > if __name___ Test Results I main Custom Input
Expert Answer:
Answer rating: 100% (QA)
Python version 36 Python program that creates and test the function playlist def playlistsongs Func... View the full answer
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Can I get the solution in Python Beauty of a path is defined asthe number of most frequently occurring alphabet. Find the mostbeautiful path and return the maximum beauty value it has. Given a...
-
Write a Python function named zeroCheck that is given three integers, and returns true if any of the integers is 0, otherwise it returns false.
-
For the following exercises, solve each inequality and write the solution in interval notation. |3x 4| 8
-
Shoppers enter Hamilton Place Mall at an average of 120 per hour. What is the probability that at least 35 shoppers will enter the mall between 5:00 and 5:10 pm?
-
Based on what you surmise Ms. Wooly is trying to get through the questionnaire, rewrite and reorder the questions (use both open-ended and closed questions) so that they follow good practice and...
-
Find all values of c such that the parabolas y = 4x 2 and x = c + 2y 2 intersect each other at right angles.
-
A chemical reaction was run 48 times. In each run, different values were chosen for the temperature in degrees Celsius (x1), the concentration of the primary reactant (x2), and the number of hours...
-
A 10-year project has an initial fixed asset investment of $38,640, an initial NWC investment of $3,680, and an annual OCF of -$58,880. The fixed asset is fully depreciated over the life of the...
-
Required information A potential investment has a cost of $395,000 and a useful life of 7 years. Annual cash sales from the investment are expected to be $237,270 and annual cash operating expenses...
-
1. Name at least three ways that Shu could automate her asset management. Suggest at least one option for retirement savings, general savings, and general convenience. 2. What major factors should...
-
What are the mechanisms underlying organelle inheritance and segregation during cell division, and how do defects in these processes contribute to genomic instability, cell cycle progression, and...
-
Please use Apriori Tid algorithm to find all the frequent item sets with Minimum Support = 4 TID Item list 100 200 300 400 500 600 700 800 900 26 1000 1100 1200 4 TID 1 2 3 4 5 6 7 00 124 245 1257 3...
-
(a) What is the need of project audit and how it can be conducted in small-sized, medium sized and large sized organization? (b) In what ways negotiations are carried out in a project and explain...
-
Q1. Consider the following network that represents the daily volume of data (in gigabyte) that can flow between six servers of BigData Company. What is the maximum amount of data that can flow from...
-
Six items are to be stored according the data given below in a storage. The storage layout arrangement is shown in the figure below with aisles width are 4.8-m. Door A serves as receiving dock and...
-
1. For the braced frame shown below, determine the horizontal deflection at C. Assume all members are pin connected at their end points and treat the structure as a truss. A = 1 in, A = 5 in, E =...
-
I am missing an argument in the parameter list dont knwo how to fix it? ParserError: Line | 3 | LocalPost, | Missing argument in parameter list. PS C:\Users\student> Get-Net TCPConnection |...
-
Assume a simple Keynesian depression economy with a multiplier of 4 and an initial equilibrium income of $3,000. Saving and investment equal $400, and assume full employment income is $4,000. a. What...
-
During the Clinton Administration, the EITC or Earned Income Tax Credit, was expanded considerably. The program provides a wage subsidy to low income families through the tax code in a way similar to...
-
A: Suppose the production process for a firm is homothetic and has decreasing returns to scale. (a) On a graph with labor on the horizontal and capital k on the vertical axis, draw an isoquant...
-
Return to the case of our beer and pizza consumption from end-of-chapter exercise 6.3. A. Again suppose you consume only beer and pizza (sold at prices p1 and p2 respectively) with an exogenously set...
-
What is a heat engine? Calculate its thermal efficiency.
-
What are the differences between a heat pump and a refrigerator?
-
\(7 \mathrm{~mol}\) of an ideal gas \(\left(C_{V}=5 \mathrm{cal} ight)\) was initially at \(30^{\circ} \mathrm{C}\) and \(2 \mathrm{~atm}\). The gas was transferred to the state when the temperature...
Study smarter with the SolutionInn App