14624 - Spiderfy Update 1.2.0   

Description

With the success of Spiderfy after a mere few weeks, a new major update is planned for the application. Being the lead developer of the application’s launch, you are now tasked with implementing a Play Queue function into the app. This function will allow users to queue up their favorite songs and play them. There are many commands that users want and it is your job to implement it.

Welcome to ‘Spiderfy Streaming Service: Project Q’!

You need to implement a list of songs that repeats itself. At first the list of songs is empty but through certain commands the user can transform the list to their preferences.

Commands:

ADD_SONG N d i
Add a song with the name N and duration d (in seconds) to the list of songs at index i. The list index starts at 0. There is a chance that users may input a value i that exceeds the length of the list, in this case just add the song to the end of the list. 

DELETE_SONG N
Delete a song with the name N. Locate a song based on their name and remove them from the list. If the song does not exist in the list, print out: “Song not found”. 

SKIP S
Move S number of songs from the front of the list to the back of the list.

REVERSE
Reverse the position of all the songs. 

PLAY t
Play the list of songs for t seconds. After t seconds has passed, print out the current playing song. Remember that the list of songs loops to itself. Print it as: “Currently playing: [song name]”.

DISPLAY
Print out “Playlist Contents:” followed by the list of songs and their duration in the playlist preceded by a “>”. If the playlist is empty, print "Playlist Contents" followed up with “-- empty --” at the next line. After printing the list of songs, regardless if the playlist is empty, print out "Playlist Duration: [total playlist duration] seconds”. (total playlist duration is set to 0 if the list of songs is empty).

Testcase Difficulty
Testcase 1: Adding and Removing Songs
Testcase 2: Adding and Removing Songs + Skip Function
Testcase 3: Adding and Removing Songs + Skip Function + ReverseFunction
Testcase 4: Adding and Removing Songs + Play Function
Testcase 5: Adding and Removing Songs + Play Function

Input

The input consists of the aforementioned list of commands:
- ADD_SONG N d i
- DELETE_SONG N
- SKIP S
- REVERSE
- PLAY t
- DISPLAY

You must do these commands until EOF. Parameter Constraints:
 

Parameter Parameter Type Size
N string 1 <= len(N) <=100 
d int 1 <= d <= 300 
i int 1 <= i <= 10,000 
S int 1 <= S <= 10,000
t int 1 <= t <= 10^9

 

Output

Print the outputs required according to each command. Enter a newline after every output unless specified otherwise. 

Sample Input  Download

Sample Output  Download




Discuss