Problem Solving Skill

Magma

Expert
Licensed User
Longtime User
My answer...

When I decide to open a cafeteria, I will consult your algorithm. In some cases, the solution is more complex or simpler than just using a formula or a specific logic—this is what makes us different from artificial intelligence as humans.
 

emexes

Expert
Licensed User
Longtime User
When I decide to open a cafeteria

If you do that, then you could just label all seats "do not sit here" except for every (K + 1)ᵗʰ seat, and there would be no need to

consult your algorithm.

🍻

although it might still be useful to know that the maximum number of diners is (N + K) / (K + 1) where "/" is integer division.
 

PaulMeuris

Well-Known Member
Licensed User
1≤K≤N : what does this constraint mean? :confused:
"Social distancing guidelines require that every diner be seated such that K seats to their left and K seats to their right (or all the remaining seats to that side if there are fewer than K) remain empty." There is no "between" in this sentence. For the first and the last diner you have to check the seats to the left of the first diner and the seats to the right of the last diner. For all the other diners you could say "between" the one on the left and the one on the right. :)
If all the constraints are checked before the calculation starts then there shouldn't be a test for M == 0 because the constraint is 1≤M≤500,000
If this puzzle test was given during a job interview then you would probably get only a couple of hours to solve the puzzle!
The purpose of such a test is to see how the applicant behaves under a stress situation and how much of the solution he or she could find.
Hopefully there will be no more social distancing...
 

Daestrum

Expert
Licensed User
Longtime User
Think if I had this asked of me, I would need to point out that household groups did not need the distancing, so could skew the results.
 

JamesDavid

New Member
You can solve this by sorting the seated positions and checking gaps. For each gap, calculate how many diners fit by dividing available seats by K+1K+1K+1. Sum across all gaps, including before the first and after the last diner.
 
Top