f=lambda r:100*sum(c/3*((v<2)*9+v)+c%3*(v<2or(v==5)/2.)for v,c in enumerate(map(r.count,range(7)))) tests = [[[1, 2, 3, 4, 5, 6], 150],[[1, 1, 1, 2, 3, 5], 1050],[[1, 1, 1, 1, 1, 1], 2000],[[2, 2, 2, 2, 2, 2], 400],[[6, 6, 1, 5, 5, 6], 800],[[2, 3, 4, 6, 2, 4], 0],[[1, 5, 1, 5, 1, 5], 1500],[[5, 5, 5, 5, 2, 3], 550],[[1, 1, 1, 1, 1, 5], 1250],[[3, 3, 4, 4, 3, 4], 700]] for test, expected in tests: result = f(test) print test, result, result==expected