Create a function that takes in the size of the line and the number of people waiting and places people in an S-shape ordering. The demonstration below will make it clear:
// Ordering numbers 1-15 in a [5,3] space.
orderPeople([5, 3], 15) ➞ [
[1, 2, 3],
[6, 5, 4],
[7, 8, 9],
[12, 11, 10],
[13, 14, 15]
]
If there is extra room, leave those spots blank with a 0 filler.
// Ordering numbers 1-5 in a [4, 3] space.
orderPeople([4, 3], 5) ➞ [
[1, 2, 3],
[0, 5, 4],
[0, 0, 0],
[0, 0, 0]
]
If there are too many people for the given dimensions, return "overcrowded".
orderPeople([4, 3], 20) ➞ "overcrowded"
orderPeople([3, 3], 8) ➞ [
[1, 2, 3],
[6, 5, 4],
[7, 8, 0]
]
orderPeople([2, 4], 5) ➞ [
[1, 2, 3, 4],
[0, 0, 0, 5]
]
orderPeople([2, 4], 10) ➞ "overcrowded"