I have an interesting algorithm to build and I have tried a couple of things but couldn't get it just right.
I have the following set of rules:
What I've tried so far (there's not a lot of svelte-specific code, mostly js):
https://svelte.dev/repl/0fc5a8e1b2a241a9985950c6a0a1ec43?version=3.44.3
https://svelte.dev/repl/c66a7de71cda46ec94fc1e11811a6883?version=3.44.3
They are similar approaches, where the first one goes over each day in the range and tries to pick people one day at a time and the second one goes over people and tries to pick all of that person's days at once.
My issue with both of those approaches is that usually there will be days where not all people are selected.
Is there a way to improve the algorithm? Do I have another way to go about this?
Any help will be greatly appreciated!