Conflict seating tables

Write codeEasy16 min

Your task

An event planner seats a guest list at identical tables. guest_names lists everyone, and conflicts holds pairs written as "ana|bo", meaning those two must never share a table. A table holds at most table_seats guests and the hall supplies as many tables as the planner asks for. Return the smallest number of tables that seats everyone while keeping every conflicting pair apart. A pair may be listed more than once and may appear in either order, and both names always come from guest_names. table_seats is at least 1, so seating each guest alone always works and gives an upper bound. An empty guest list needs no tables, so return 0. There are at most 8 guests.

Examples

fewest_banquet_tables(guest_names: list[str], conflicts: list[str], table_seats: int) -> int
Example 1
Inputfewest_banquet_tables(["ana", "bo", "cy", "dee"], ["ana|bo", "cy|dee"], 2)
Output2
Example 2
Inputfewest_banquet_tables(["ana", "bo", "cy"], ["ana|bo", "bo|cy", "ana|cy"], 4)
Output3
Example 3
Inputfewest_banquet_tables(["ana", "bo", "cy", "dee"], [], 1)
Output4