zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    2020软件工程作业02
    2020软件工程作业01
    并发编程—协程
    并发编程—线程
    并发编程—进程
    python网络编程总结
    前端-Javascript
    前端-jQuery
    前端-CSS
    前端-Html
  • 原文地址:https://www.cnblogs.com/snow-backup/p/4381540.html
Copyright © 2011-2022 走看看