✅

To-Do Manager

Add, complete, delete, search and filter tasks with priorities — driven by simple commands.

Project 4Intermediate

🧩 Problem statement

Process a list of commands and keep a to-do list. Commands: “add:TASK:PRIORITY”, “done:TASK”, “delete:TASK”, “list” (show tasks not done, highest priority first — priority 1 is highest — as “[P] TASK”), “search:TEXT” (show tasks containing TEXT).

📋 Requirements

  • Add task
  • Complete task
  • Delete task
  • Search
  • Filter (not done)
  • Priority ordering

📥 Inputs

  • COMMANDS: a list of text commands

📤 Outputs

  • Output of each list/search command

📏 Rules

  • Priority 1 is the most important
  • Done tasks are hidden from list

🚧 Constraints

  • Task names are unique

🧭 Suggested approach

  • Store tasks as a map: name → {priority, done}
  • Split each command with SPLIT(CMD, ":")
  • For list: collect not-done tasks and sort by priority

🧠 Required concepts

  • Maps
  • Strings
  • Sorting
  • Functions
✏️ Pseudocode editor · dry-run tool · test cases

Design your solution here. Use Run to dry-run it step by step and Run tests to check it. Hints unlock one at a time — try on your own first!

🧪 Edge cases to test

  • Listing when everything is done
  • Deleting a task that doesn’t exist (extension: show a message)
  • Search with different capital letters

📈 Complexity analysis

Each add/done/delete is O(1) with a map; list is O(5 × n); search is O(n × text length).

📖 Solution walkthrough (open after you’ve tried!)

Tasks live in a map so done/delete are instant lookups. Each command is split on ":" into its parts. Listing walks priorities 1 to 5 and shows unfinished tasks at each level — a simple way to sort by priority without a sort function. Search compares lower-case versions so capitals don’t matter.

🚀 Challenge extensions

  • Show a message when a task doesn’t exist
  • Add due dates and an “overdue” filter
  • Count done vs remaining tasks

← All projects