SRM146 DIV2 250

一般编程题

 1 class YahtzeeScore:
 2     def maxPoints(self, toss):
 3         count = [0] * 7
 4         for x in toss:
 5             count[x] += 1
 6         result = -1
 7         for i in range(1, 7):
 8             result = max(result, i * count[i])
 9         return result
10 
11 # test
12 o = YahtzeeScore()
13 
14 # test case
15 assert(o.maxPoints((2, 2, 3, 5, 4)) == 5)
16 assert(o.maxPoints((6, 4, 1, 1, 3)) == 6)
17 assert(o.maxPoints((5, 3, 5, 3, 3)) == 10)
View Code

 

posted @ 2013-11-25 07:35  valaxy  阅读(116)  评论(0)    收藏  举报