I have a seating arrangement in string format with category like this:
const seats =
'_VCCCCVVVVVVVVVV_/' +
'_________________/' +
'_U__GGGGCCGGG__C_/' +
'_U__GGGGCCGGG__C_/' +
'_U__GGGGGGGGG__C_/' +
'_U__GGGGGGGGG__C_/' +
'_________________/'
// V -> VIP v -> VIP (booked)
// C -> Charter c -> Charter (booked)
// G -> General g -> General (booked)
// _ -> empty space
// / -> new row
// U -> unavailable
I have member details like this in format:
UID: [Member No., Category, Family Name, Mobile, Gender]
const memberDetails = {
1006: [
['1', 'Charter', 'Family 1', '9999999', 'M'],
['2', 'Charter', 'Family 1', '9999999', 'F'],
['3', 'Charter', 'Family 1', '9999999', 'M'],
['4', 'Charter', 'Family 1', '9999999', 'M'],
],
1002: [
['1', 'General', 'Family 2', '999999999', 'M'],
['2', 'General', 'Family 2', '999999999', 'F'],
],
}
I want to assign these seats to the registered member, but there are constraints:
Each member should get a seat
Families should be seated next to each other as much as possible, although breaking a large family into smaller chunks should be fine.(eg: family of 7 -> 4 + 3)
Hence I assign the seats to large families first such that the gaps can be filled later on when small families are assigned.
The Problem
Larger families get seats always towards the top left (as I'm looking from left to right), is there any way I can randomise this process such that the families dont get the same seats each time?