换算成拍数差多少
运行下面这段程序,填写它打印出来的结果。
STAGES = 5
def one_by_one(n):
return n * STAGES
def pipelined(n):
return n + STAGES - 1
def wrong_guesses(pattern):
last = -1
wrong = 0
for t in pattern:
if last == -1 or t != last:
wrong = wrong + 1
last = t
return wrong
FLUSH = 3
raw = [1, 0, 1, 1, 0, 0, 1, 0]
sortd = sorted(raw)
a = pipelined(8) + wrong_guesses(raw) * FLUSH
b = pipelined(8) + wrong_guesses(sortd) * FLUSH
print(str(a) + "/" + str(b) + "/" + str(round(a / b, 2)))
全部评论