We are asked to organize a table to maximize happiness on this puzzle. It is a round table and the gain/lose happiness is your input data. For example, if Alice is sitting next to Bob the table will gain 54 happiness units, but if Alice is sitting next to Carol, 79 happiness units will be lost. The solution to the puzzle is to find the maximum possible happiness unit.
First, we need to convert the string representing the gain/loss of happiness for people into a data type we could work with:
On the input, there are not too many people; so, we can find all the permutations and calculate the total happiness value and then find the maximum:
The second puzzle is the same but adding yourself and assuming your happiness is independent of who is sitting beside you (for all people, zero gain):
You can find this code along with my input and puzzle answers at here.