Created
November 26, 2025 18:11
-
-
Save goofballLogic/07d3a6886e50cb2759e28689e509ecd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const taskListEndsAt = ts => | |
| Math.max(...ts.map(t => t[2])); | |
| const maybeAdd = (ts, candidate) => | |
| (taskListEndsAt(ts) <= candidate[1]) | |
| ? [ts, [...ts, candidate]] | |
| : [ts] | |
| ; | |
| const combinations = ts => | |
| ts.reduce( | |
| (combinations, t) => | |
| [ | |
| ...combinations.flatMap(c => maybeAdd(c, t)), | |
| [t] | |
| ], | |
| [] | |
| ); | |
| const choose = ts => | |
| combinations(ts).reduce( | |
| (found, cs) => (cs.length > found.length) ? cs : found, | |
| [] | |
| ); | |
| const summarise = chosen => | |
| ({ | |
| count: chosen.length, | |
| chosen: chosen.map(x => x[0]) | |
| }); | |
| const maxMealPrepTasks = ts => | |
| summarise(choose(ts)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment