Back to Challenge Set 23

Code Challenge: Metadata Search

Difficulty  

divider

The Brief

What they asked for
Road trip tomorrow. I want a playlist of one genre and I need
to know how long it runs before I build it. My phone is slow,
so do not make me wait while it plays every song to check.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Everything you need is in the metadata: title, genre and length in seconds, as parallel arrays that stay lined up. The songs themselves are never touched, and that is the whole point of the brief.
  • Report the count and the total running time, not just the matches. How long it runs is a requirement.
  • Show lengths as minutes and seconds, the way a music app does. / 60 and % 60 are all you need.
  • Handle a genre with no songs in it.
  • Print how many songs you played. The answer should be zero, and printing it is how you prove you met the brief.

Sample Output

Sample Output
synthwave:
Night Drive 3:12
Static Sky 5:01
Slow Tide 4:36
3 songs, 12 minutes 49 seconds
folk:
Lowlands 4:05
Paper Boats 3:08
2 songs, 7 minutes 13 seconds
jazz:
none
Songs played: 0

That last line is the deliverable. Metadata is what lets you answer a question about a thousand files without opening any of them. (Writing {seconds % 60:D2} pads one-digit seconds to two digits, as in 5:01; the plain number is fine.)


Submit

Your requirements list and your program file, named cc-metadata-search.

Commence Challenge