Dice chrone execise

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)

 

posted @ 2015-03-31 17:22  道以万计  阅读(210)  评论(0编辑  收藏  举报