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, returning the result as string. The demonstration below will make it clear:
# Ordering numbers 1-15 in a 5 x 3 space.
OrderPeople(5, 3, 15) ➞
1, 2, 3
6, 5, 4
7, 8, 9
12, 11, 10
13, 14, 15If there is extra room, leave those spots blank with a 0 filler.
# Ordering numbers 1-5 in a 4 x 3 space.
OrderPeople(4, 3, 5) ➞
1, 2, 3
0, 5, 4,
0, 0, 0,
0, 0, 0If 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""1, 2, 3\n6, 5, 4\n7, 8, 9\n12, 11, 10\n13, 14, 15". Note the spacing of the numbers and the new line character \n between each row.