我正在编写一个随机选择Rubik的立方体算法进行练习的代码,但我不想两次获得相同的数字。我怎样才能做到这一点?这是我的代码:
import random
one = 'Fi U2 Fi U2 F2 U2 Fi Ri Fi Di F2 D'
two = 'Ri Ui Fi U F R F2 U F2 Di F2 D R2'
three = 'Fi U2 F2 U F2 U F L2 B L Bi L'
four = 'Bi Li B2 L Bi R2 Di F2 U F2 R2 D'
print("How many scrambles do ypu want?")
try:
qty = int(input("Scrambles: "))
except ValueError:
print("please write a number")
for i in range(0, qty):
scramble = random.randint(0, 4)
#print (scramble)
if scramble == 1:
print(one)
elif scramble == 2:
print(two)
elif scramble == 3:
print(three)
elif scramble == 4:
print(four)