Fitting circular tables in a rectangular restaurant

# Question: How many circular tables of known diameter, arranged in circle packing layout should be ordered to fill a given restaurant area while allowing for convenient service? pi = 3.14159265359 # save import inch_to_cm = 2.54 cm_in_m = 100 restaurant_area_width_m, restaurant_area_length_m = 12, 9 available_restaurant_area_m2 = restaurant_area_width_m * restaurant_area_length_m table_diameter_inches = 36 # circular shape chair_width_inches, chair_depth_inches = 16.75, 16.5 chairs_per_table = 4 # chairs against each other chair_slack_space = 0.25 * chair_depth_inches # space between chair and table people_fitting_in_walkway_width = 2.4 # e,g clients and personnel must be able to pass each other without trouble or guests sitting on their way person_width_inches = chair_width_inches walkway_width_inches = people_fitting_in_walkway_width * person_width_inches max_table_and_chair_width_inches = table_diameter_inches + (chairs_per_table/2) * (chair_depth_inches + chair_slack_space) table_chair_walkway_width_inches = max_table_and_chair_width_inches + walkway_width_inches # two halves on both sides table_chair_walkway_width_m = (table_chair_walkway_width_inches * inch_to_cm) / cm_in_m table_chhair_walkway_area_m2 = pi * table_chair_walkway_width_m**2 / 4 tables_in_width = restaurant_area_width_m // table_chair_walkway_width_m tables_in_length = restaurant_area_length_m // table_chair_walkway_width_m tables_fitting = tables_in_width * tables_in_length print('The restaurant could order %d tables (with %d seats).' % (tables_fitting, tables_fitting * chairs_per_table)) print('Theoretical limit: %d tables' % (available_restaurant_area_m2 // table_chhair_walkway_area_m2)) # The restaurant could order 12 tables (with 48 seats). # Theoretical limit: 15 tables # With regular packing, an area equivalent to 3 tables is lost in the spaces between tables. Different table settings in the restaurant area

It is possible to rotate the chairs by 45° in the first case to make more space on the walkways.