首页 > 其他 > 详细

Dice chrone execise

时间:2015-03-31 19:25:22      阅读:258      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!