from random import randint def scramble3(): a=0 b=0 c=0 scramble = "" turns=['U','F','R','L','B','D'] directions=['\' ', '2 ', ' '] for x in range(25): while c==b: c=randint(0,5) if c==a and a+b==5: d=c while c==d or c==b: c=randint(0,5) scramble+=turns[c] d=randint(0,2) scramble+=directions[d] a=b b=c return scramble def scramble4(): moves=['R','U','F','L','D','B','r','u','f','l','d','b'] turns=[' ', '\' ', '2 '] check=[0,0,0,0] prem=randint(0,11) scramble="" for i in range(40): m=randint(0,11) while m==prem: m=randint(0,11) if m%3==prem%3: x=m/3 if x==3 or x==2: y=swap(x) else: y=x while check[x]==1 or check[y]==1: m=randint(0,11) if m%3!=prem%3: check=[0,0,0,0] if x==3 or x==2: y=swap(x) else: y=x else: check=[0,0,0,0] check[m/3]=1 x=randint(0,2) scramble+=moves[m]+turns[x] prem=m return scramble def scramble2(): turns = ['\' ', '2 ', ' '] faces = ['U', 'F', 'R'] x = randint(0,2); z = randint(0,2); axis=x; scramble="" for j in range(15): while x==axis: x = randint(0,2) z = randint(0,2) scramble+=faces[x]+turns[z] axis=x return scramble def scramble2g(): turns=['\' ', '2 ', ' '] scramble="" for x in range(8): scramble+='R'+turns[randint(0,2)]+'U'+turns[randint(0,2)] return scramble def scrambleroux(): turns=['\' ', '2 ', ' '] scramble="" for x in range(8): scramble+='M'+turns[randint(0,2)]+'U'+turns[randint(0,2)] return scramble def swap(x): if x%2==0: return x+1 return x-1 scrambles={'3':scramble3,'4':scramble4,'2g':scramble2g,'roux':scrambleroux, '2':scramble2} ans='' print "Options are: %s" % ' '.join(scrambles.keys()) while True: ans=raw_input("") try: print scrambles[ans]() except KeyError: print "Invalid option" print "Options are: %s" % ' '.join(scrambles.keys())