You may have encountered a problem on Brilliant about seating people around a long table made out of n-sided tables of equal side lengths. This one goes a little bit further.
You are preparing a big feast. You need to create one long table from small regular shaped n-lateral tables. We illustrate this in the picture bellow. You may seat one and only one person at each side of the small table.
What is the sum of all posible side numbers (triangle = 3, square = 4 etc.) you can use to seat 112 people?
Although this can be done on paper, try to use some code and let the computer do the job!
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
To find a pattern we will look into the example of, number of sides = 5
For one table, S i d e s A v a i l a b l e = 5
For two tables, one side of each table is joined, thus unusable, so the result would be, S i d e s A v a i l a b l e = ( 5 − 1 ) × 2 = 8
For three tables,
One side of each end table is joined with an adjacent table, so only 4 sides are usable. S i d e s A v a i l a b l e = 2 × ( 5 − 1 )
And for each table with two adjacent tables, will have two adjoined sides thus only 3 sides are usable, S i d e s A v a i l a b l e = 1 × ( 5 − 2 )
T o t a l S i d e s A v a i l a b l e = 2 × ( 5 − 1 ) + 1 × ( 5 − 2 ) = 1 1
For n - tables,
Finally, T o t a l S i d e s A v a i l a b l e = 2 × ( 5 − 1 ) + ( n − 2 ) × ( 5 − 2 )
Sides Required = 112.
On solving, we get n = 3 6 . 6 6 . . .
Since it is not a whole number, it will not contribute to the result.
So the final problem would be,
n = number of shapes,
m = number of sides of the shapes
1 1 2 = 2 × ( m − 1 ) + ( n − 2 ) × ( m − 2 )
On rearranging, we get, m = n − 2 1 1 2 − 2 × ( n − 1 )
Thus the Python Code will be
1 2 3 4 5 6 7 8 9 10 11 |
|
Output :
Result = 232
Did you want to post this as a separate solution or a comment to Chris Lewis' solution?
First, we need to find the pattern. Except for the first and last table, you can seat n − 2 people around each small table. This means, that for n-sided table, number of available seats S = T ( n − 2 ) + 2 , where T is the number of used tables. Thus the folowing must apply: ( n − 2 ) ∣ ( S − 2 ) . Now, we can write a function in python:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The output after calling
1 |
|
looks like this:
1 |
|
I have a different answer. 225. The different n-laterals are following:
112 (one 112-gon, 0 places lost)
57 (two 57-gons, 2 places lost),
24 (five 24-gons, 8 places lost),
13 (ten 13-gons, 18 places lost),
12 (eleven 12-gons, 20 places lost)
4 (55x 4-gons, 108 places lost)
3 (110x 3-gons, 218 places lost)
112+57+24+13+12+4+3=225 mistake?
Edit: 22x 7-gons added to the list (42 places lost) 225+7=232
Lets have m n -sided tables.
There are m n total sides, of which 2 ( m − 1 ) are paired together. Thus leaving ( n − 2 ) m + 2 spaces.
Hence, ( n − 2 ) m = 1 1 0 .
m , ( n − 2 ) ∈ 1 , 2 , 5 , 1 0 , 1 1 , 2 2 , 5 5 , 1 1 0 .
n ∈ S = 3 , 4 , 7 , 1 2 , 1 3 , 2 4 , 5 7 , 1 1 2 with s u m ( S ) = 2 3 2 .
Didn't use Python as at the point I split the problem down to something to program all I was doing was factorising, but with a larger amount of people, a good factoring algorithm would be good to implement.
Sorry I don't know how to post python solution.Please let me know.
Here is the code -
count = 0
for n in range( 3 , 113 ):
if 110 % (n - 2) == 0:
count += n
print (count)
cool, could you hint me " 110%(n-2) " , what does mean ?
Sorry for this late, '%' operator is used to calculate modulo in Python
k n-gons offer seat to ( n − 2 ) k + 2 people. 110=2×5×11 has 8 divisors 1 , 2 , 5 , 1 0 , 1 1 , 2 2 , 5 5 , 1 1 0 , so the sum of possible n is 8 × 2 + 1 + 2 + 5 + 1 0 + 1 1 + 2 2 + 5 5 + 1 1 0 = 2 3 2 . I do not see why coding would save work.
Another possible solution (made in C#), however not as efficient as the solution from the original poster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
Output when it runs:
1 |
|
i = 3
solutions = []
while i < 113:
diff = i - 2 #diff is the number of people added to the big table when each new i-gon is added on the end
j = i
while j < 113: #this loop adds more i-gons to the big table
j = j + diff
if (j == 112):
print(i,diff,j) #just for my edification
solutions.append(i)
i = i+1
solutions [3, 4, 7, 12, 13, 24, 57]
For answer: sum up entries in solutions list.
So...the answer is 120! Whoops, I forgot the 112-sided table! The answer is 232!
Problem Loading...
Note Loading...
Set Loading...
One obvious solution is a single, 1 1 2 -sided table.
For the other cases, we have more than one table.
Say we put n small, s -sided tables together to form the large table.
The two end tables have s − 1 seats available. The other n − 2 tables have s − 2 seats available. So we need
2 ( s − 1 ) + ( n − 2 ) ( s − 2 ) = 2 + n ( s − 2 ) = 1 1 2 , with n > 1 .
This means we're looking at proper divisors of 1 1 0 :
s − 2 ∈ { 1 , 2 , 5 , 1 0 , 1 1 , 2 2 , 5 5 }
Summing all possible s (including the single table solution) gives the answer 2 3 2 .