We need to create a system to calculate the general ranking for a horse racing championship that consist on several races.  There are 2 types of races, with different ranking system:  Trial Race: 1st gets 10 points 2nd gets 7 points 3rd 3 points 4th 1 point  Classic Race: 1st gets 25 points 2nd gets 18 points 3rd gets 10 points 4th gets 2 points  Furthermore, the horses can get penalties due to bad behaviour during the race. Penalties remove 3 points from the horse ranking.  An example would be the following:  Trial Race --------------- 1st "Horsy" 2nd "John the little horse" 3rd "Always places third"  Classic Race ------------------ 1st "John the little horse" 2nd "Horsy" 3rd "Always places third"   With a penalti for "John the little horse", the final championship ranking would be  John the little horse 29 points Horsy 28 points Always places third 13 points