Skip to content

Instantly share code, notes, and snippets.

@lessandro
Last active December 13, 2015 17:19
Show Gist options
  • Save lessandro/80c7e5a37378afcb8137 to your computer and use it in GitHub Desktop.
Save lessandro/80c7e5a37378afcb8137 to your computer and use it in GitHub Desktop.

Problem

If you're not familiar with brazilian carnaval, we have these huge parades where traditional samba schools compete for fun and fame. Each school has 1 hour at the Sambadrome to do their thing, and while doing so they're being ruthlessly judged by 5 judges, who later have to assign 9 scores about the parade. They score specific things such as costumes, theme, evolution, harmony, battery, etc.

Write a program that reads these scores from a csv file and prints out the winner school.

Scoring

To determine the winner, for each school, and for each score category, you discard the lowest and largest score, and then sum the remaining 3 scores. For instance, if a school received scores [10, 9.8, 9.9, 10, 10] for score category "costumes", you discard the lowest score (9.8) and the largest score (10), and sum the rest [10, 10, 9.9], which results in 29.9.

Then you just sum the scores for all categories to compute the final score for a school. Take a look at this page for an actual example of this year's parade.

Input

Your input is a csv file with the scores of 14 schools. Each column is a score category (9 categories), each row is a score (5 scores for each category). The scores for a school are preceded by the school name in a single row.

Output

The winner school, and its final score.

Mocidade
9.9 10 10 9.3 9.9 10 10 10 10
10 10 10 10 9.9 10 10 10 10
10 10 10 9.8 10 9.9 10 10 10
10 9.8 10 9.9 9.9 9.9 10 10 10
9.9 10 10 9.7 10 9.8 10 10 10
Rosas de Ouro
10 9.9 10 9.7 10 10 10 10 9.8
10 10 10 10 10 10 10 9.7 10
10 10 10 9.9 10 10 10 9.6 10
10 9.5 10 10 10 9.9 10 10 9.9
10 9.9 10 9.8 10 9.8 10 9.9 10
Águia de Ouro
10 10 10 10 10 10 10 10 10
10 10 10 10 9.9 10 10 10 10
10 10 10 10 10 10 10 9.7 10
10 9.5 10 10 10 9.9 10 10 9.9
10 10 9.9 10 10 9.9 10 10 9.9
Dragões da Real
10 9.6 10 10 10 10 10 10 10
10 10 9.8 9.9 9.9 10 10 10 9.9
10 10 10 9.9 10 9.7 10 10 10
10 9.5 9.9 9.7 10 10 10 9.9 10
9.9 9.7 9.9 9.7 9.9 10 10 10 10
Império de Casa Verde
9.9 10 10 10 9.7 10 10 10 10
9.9 10 10 10 9.8 10 10 9.7 10
9.8 10 9.8 10 9.9 10 10 9.9 10
9.7 9.8 9.9 9.9 9.8 9.9 10 9.9 9.7
9.9 10 10 9.9 9.9 9.9 9.9 10 9.9
Acadêmicos do Tucuruvi
9.8 9.7 10 9.8 9.9 10 9.8 9.9 10
9.9 9.9 10 10 10 9.9 10 10 10
10 9.7 10 10 9.8 9.8 10 10 10
9.9 9.7 10 10 9.9 10 10 9.7 10
10 9.6 10 10 9.8 10 10 10 10
Vai-Vai
9.8 9.9 10 9.8 10 10 10 10 10
9.8 9.8 10 10 9.8 10 10 9.9 10
9.9 10 10 10 9.9 10 10 9.7 10
9.9 9.7 10 10 10 10 10 10 10
9.8 9.6 10 9.7 9.9 10 10 9.7 10
Nenê de Vila Matilde
10 10 10 9.7 9.8 10 10 9.9 10
10 10 10 9.9 9.7 9.8 10 10 10
10 9.9 9.9 9.7 9.9 10 10 9.9 9.8
10 9.7 9.8 9.8 9.8 10 10 9.7 10
9.9 9.8 9.9 10 9.9 10 9.9 9.9 9.9
Gaviões da Fiel
9.9 10 10 9.6 9.9 10 10 10 10
10 10 9.8 10 9.9 10 10 9.9 9.9
9.8 9.8 10 9.9 10 10 10 9.9 10
9.9 9.7 9.9 10 9.8 9.9 10 9.9 9.6
9.9 9.5 9.9 9.9 10 9.9 10 9.8 9.9
X-9
10 10 10 9.9 10 10 10 10 9.7
10 9.9 10 10 9.8 9.8 10 10 10
10 10 10 9.8 9.9 9.9 10 9.9 9.9
10 9.4 10 9.6 10 9.7 10 10 10
10 9.8 10 9.6 9.8 9.9 10 10 9.8
Acadêmicos do Tatuapé
9.9 9.7 10 9.5 10 10 9.8 9.7 10
9.9 9.9 10 9.9 9.9 9.9 10 9.5 9.8
9.9 10 10 9.9 10 9.4 10 10 10
10 9.4 10 9.9 9.7 10 9.9 9.8 10
9.9 9.8 9.9 9.7 9.9 10 10 10 10
Tom Maior
10 9.6 9.9 9.3 10 10 10 10 10
10 9.9 10 9.9 10 10 9.9 10 9.8
10 9.9 10 9.9 10 9.7 10 10 9.8
9.8 9.6 9.9 9.8 10 9.8 10 10 9.7
10 9.7 9.9 9.9 9.9 9.7 10 10 10
Mancha Verde
9.9 10 10 10 10 10 9.9 9.9 9.9
9.9 9.9 9.9 10 10 9.9 10 9.7 9.9
9.9 10 9.8 10 9.9 9.7 10 9.7 10
9.9 9.7 9.8 10 10 9.8 10 9.9 9.8
10 9.9 9.8 9.8 9.9 9.8 10 10 9.9
Unidos de Vila Maria
9.9 9.5 10 10 9.8 10 10 9.8 9.8
9.9 10 9.6 9.9 10 10 10 9.9 10
10 10 9.6 10 9.9 10 10 9.7 10
9.9 9.7 9.9 10 10 9.9 10 9.9 9.8
9.9 9.7 10 9.9 10 9.7 10 10 9.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment