Created
November 26, 2025 18:27
-
-
Save goofballLogic/4f235b85d11bf0f8578ad8337c28c6e6 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 maybeAdd = (prev, candidate) => | |
| prev.endsAt <= candidate[1] | |
| ? [prev, { | |
| chosen: [...prev.chosen, candidate[0]], | |
| endsAt: candidate[2] | |
| }] | |
| : [prev]; | |
| const combine = ts => | |
| ts.reduce( | |
| (cs, t) => cs.flatMap(prev => maybeAdd(prev, t)), | |
| [{ chosen: [], endsAt: 0 }] | |
| ); | |
| const choose = cs => | |
| cs.reduce( | |
| (found, candidate) => found.chosen.length > candidate.chosen.length | |
| ? found | |
| : candidate); | |
| const summarize = x => | |
| ({ | |
| count: x.chosen.length, | |
| chosen: x.chosen | |
| }); | |
| const maxMealPrepTasks = ts => | |
| summarize(choose(combine(ts))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment