Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Playlist Chaos — Solution

This is the reference solution for the AI110 Module 1 Tinker Playlist Chaos. It is the starter app with every planted bug fixed, so you can compare it against the version you debugged in the lab. It is not the only correct implementation — if your app behaves the way this one does, you're in good shape.

Starter repo: ai110-module1tinker-playlistchaos-starter

Run it

pip install -r requirements.txt
streamlit run app.py

How the code is organized

  • app.py — the Streamlit UI (mood profile, add-song form, playlist tabs, search, lucky pick, stats, history). Unchanged from the starter; no bugs live here.
  • playlist_logic.py — all classification, stats, search, and lucky-pick logic. All five fixes are here.

What was fixed

The starter had five bugs. Each one below matches the Intended Behavior Overview in the Tinker.

  1. classify_song — priority + keyword case. Chill conditions are now checked before the Hype conditions, so a favorite-genre match can no longer drag a genuinely low-energy song into Hype. Chill keyword matching compares against the lowercased title, so "Lofi Rain" matches "lofi".
  2. compute_playlist_statshype_ratio. The ratio now divides by the total number of songs instead of by the Hype count (which made the ratio always 1.0).
  3. compute_playlist_statsavg_energy. Average energy now sums energy across all songs, not just the Hype list.
  4. search_songs — inverted substring check. The match is now query in value (e.g. searching "AC" finds "AC/DC"), not the backwards value in query.
  5. random_choice_or_none — empty list. Returns None on an empty list instead of raising IndexError, keeping Lucky Pick safe when a playlist is empty.

How to check your own work

Add an ambient, low-energy song and confirm it lands in Chill. Add several low-energy songs and confirm Average Energy and Hype Ratio reflect the whole library. Search a partial artist string. Run Lucky Pick on an empty playlist. All four should behave sensibly — no wrong buckets, no stuck ratios, no crashes.

About

Reference solution for the AI110 Module 1 Tinker: Playlist Chaos

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages