Py||Basketball game

题目描述
The NBA has a comprehensive judgment index for the player’s technical statistics - the efficiency value, which is calculated as:

efficiency value = [(score + rebound + assists + steal + block) - (number of shots - number of hits) - (number of free throws - The number of successful free throws) - the number of turnovers,

now you need to write a program to calculate the player’s efficiency value based on the technical statistics string of the player’s single game. The technical statistics string contains various basketball game data, corresponding to the following:
1Y- one successful free throw and get 1 score
1N - one missed free throw without the score
2Y - one successful shooting with 2 scores
2N - one missed shooting without a score
3Y - one successful three-points shooting get 3 scores
3N- one missed three-points shooting without a score
R-rebound
A-assisted
S- steal
B- block
T-turnover
Note: The number of shots = 2Y+2N+3Y+3N, the score is calculated as: 1 point for a free throw, 2 points for a two-pointer, and 3 points for a three-pointer.

输入
The input includes multiple lines of data, each line represents a technical statistic string of a player’s single game, such as 1Y1N2Y2N3Y3NRASBT, indicating that the player has two “free throw” and one get score, has two “two 2-point shooting” and one get score, has two “three-point shooting” and one get score, and the player has 1 rebound, 1 assist, 1 steal, 1 block, 1 turnover, 4 shots.
Each line of technical statistics string does not contain other characters and does not exceed 1000 characters.

输出
For each line of input, output the player’s efficiency value, such as the efficiency value of 1Y1N2Y2N3Y3NRASBT is (6+1+1+1+1)-(4-2)-(2-1)-1=6

样例输入 Copy
1Y1N2Y2N3Y3NRASBT
1Y1Y
样例输出 Copy
6
2

while True:
    s=[]
    s=[str(i) for i in input()]
    flag=0
    num=num2=num3=num4=score=0
    for i in s:
        if i=='1':
            flag=1
            num=num+1
        if i=='2':
            flag=2
            num=num+1
        if i=='3':
            flag=3
            num=num+1
        if flag!=0:
            if i=='Y':
                score=score+flag
                num4=num4+1
                flag=0
        if i=='R':
            num2=num2+1
        if i=='A':
            num2=num2+1
        if i=='S':
            num2=num2+1
        if i=='B':
            num2=num2+1
        if i=='T':
            num3=num3+1
    print(score+num2-num+num4-num3)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值