Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

316
Visualizações
Algorithm to fit people in a monthly calendar

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:

  • 16 people to fill every day of the month (let's call it 28 days to make it even weeks)
  • 4 people per day
  • Each person should have a maximum of 7 days a month
  • There has to be two days between each picked day (so if Person1 has a Monday, they shouldn't have another shift on Saturday-Sunday before nor Tuesday-Wednesday after)
  • Each person should have a free weekend during the month (we include Fridays during weekends, so no shifts on Fri-Sat-Sun once)

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!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda