A solution for 1Computer1‘s “tasks“ challenge, solved in Haskell.
“Odd Jobs“ is the title for one of the 4 programming challenges made up by 1Computer1 with no reward except the euphoric rush of finally seeing your program run successfully after extensive amounts of trial and error.
The “Odd Jobs“ challenge gives you 3 non-negative integers; N, M and D.
Integer N specifies the lines of tasks which are obligatory. Whereas the M integer specifies the lines of tasks which are not obligatory, but rather optional. And finally, the D integer specifies dependencies in the format
Task A, Task B -> Task C, Task D
Meaning, in order to complete
Task C and Task D, both Task A and Task B must be completed before-hand.
My personal approach to solving the problem was quite inefficient, and there are definitely much better approaches to this.
Nonetheless, the outputs from the inputs yield the expected results. However, they are not ordered the same.
The way my solution works is by obtaining the input via the terminal, obtaining it, parsing it into pairs (obligatory tasks, optional tasks and dependencies), and from there on saving the obligatory tasks into a list of completed tasks, then splitting the dependencies into two parts:
-
requirements
-
tasks to do
Below is a snippet of all of the inputs and outputs of each task example:

