task dependencies
Let's say you're writing a project management app. A user will have a bunch of tasks to do and each task might depend on other tasks. Your challenge is to write a function that, given tasks and dependencies, gives at least one order for the tasks such that no task is done before its dependencies are done.
(def tasks [:clean-breakfast :shoes :socks :cook-breakfast :eat-breakfast])
(def dependencies [[:socks :shoes] ;; socks come before shoes; shoes depend on socks
[:cook-breakfast :eat-breakfast] ;; cooking comes before eating
[:eat-breakfast :clean-breakfast]])
(defn order-tasks [tasks dependencies]
;; you fill this out
)
(order-tasks tasks dependencies) => [:socks :shoes :cook-breakfast :eat-breakfast :clean-breakfast]