Skip to the workspace
Pebellslearn by building
Foundations: Complexity & Arrays  ›  Capstone Project

Capstone — Library Dashboard

35 minOne O(t + p) pass that combines an index, counts and a sliding window

dsa / Capstone — Library Dashboard

Explore each scene at your own pace.

01 · What you're building

What you're building

Capstone — Library Dashboard

Definition
The library dashboard combines an index, a cleaned play log, counts, leaders and a two-pointer window in one function, so every figure comes from a few single passes over the data and the total cost stays O(t + p).
In plain words
It is a control panel fed by several small tools, each doing one job in one pass: build the index, tidy the log, count, pick the leaders, find the session. The skill is choosing the right structure for each job so nothing is searched twice.

In short: every lesson in this section built one piece of Tunebox's library — the scale planner, the playlist, the session finder, the song index. The home screen's library dashboard runs them together: library size, plays, top track and artist, and the longest session that fits your free time, all from one function, library_dashboard(), on every refresh. A real library is messy and a real play log is long, so it must stay O(t + p) for t tracks and p plays — a pass or two over each, never a loop inside a loop, never in on a list, never pop(0).

Four pipes feeding into one dashboard box: 'index' and 'clean log' feed 'counts', which feeds 'leaders', while 'clean log' also feeds 'session' straight — each pipe labelled with its one-pass cost

What you're building

library_dashboard(tracks, plays, budget)
  • tracks — the library, a list of dicts like {"id": "t1", "title": "Glow", "artist": "Nova", "mins": 4}. A messy import can list the same id twice; the first copy is the real track.
  • plays — the play log: track ids in the order they were played. Ids that aren't in the library (deleted tracks) are ignored.
  • budget — a number of minutes.
Scene 1 of 11
Project context and further resources
You're building a piece ofTunebox — the library
This piece — library_dashboard(): Ties the index, playlist and sessions into one library summary.
Scenario Tunebox's home screen opens on a library dashboard. It has to summarise a messy library and a long play log on every refresh, so it combines the song index, the play log array and the session finder in one O(t + p) function.
library_dashboard.py
Call the function you wrote — just like your app's frontend would. Edit the inputs and hit Call.
library_dashboard(tracks, plays, budget) → dictThe library summary: size, plays, minutes, leaders and the longest session within budget.
try:
returned
Press Run to execute your code.
Press Check to run the tests for this lesson.
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.