码迷,mamicode.com
首页 > 其他好文 > 详细

Dice chrone execise

时间:2015-03-31 19:27:20      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

def score(dices_input):
    count = {}.fromkeys(range(1, 7), 0)
    points = 0
    for dice_side in dices_input:
        count[dice_side] += 1
    # print count
    points = (count[1]/3)*1000 + (count[1]%3)*100 + (count[5]%3)*50
    for i in range(2, 7):
        points += (count[i]/3) * i * 100
                
    return points

if __name__=="__main__":
    print "The score of the given examples:"
    print "score[1,1,1,5,1]=%d" %score([1,1,1,5,1])
    print "score[2,3,4,6,2]=%d" %score([2,3,4,6,2])
    print "score[3,4,5,3,3]=%d" %score([3,4,5,3,3])
    print "score[1,5,1,2,4]=%d" %score([1,5,1,2,4])
    print "You can try others"
    a=raw_input("Input five numbers:")
    input_s=[0,0,0,0,0]
    if len(a.split())!=0:
        b=a.split()
    for i in range(len(input_s)):
        input_s[i]=int(b[i])
    print score(input_s)

 

Dice chrone execise

标签:

原文地址:http://www.cnblogs.com/snow-backup/p/4381540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!