Share your repls and programming experiences

← Back to all posts
Rubik's cube scramble generator
RhinoRunner (864)

This scrambler generates scrambles depending on which cube you choose

Cubes:

  1. 3x3x3
  2. 2x2x2
  3. Pyraminx
  4. Ivy cube

Choose the number for the cube you want and then press enter.

If you want a new scramble, press enter.

Comments
hotnewtop
Bunnytoes (165)

I also added skewb to it I had to copy the entire code
import random, sys, os

scrambles3x3 = ["R","R'","R2","L","L'","L2","U","U'","U2","D","D'","D2","F","F'","F2","B","B'","B2"]
scrambles2x2 = ["R","R'","R2","L","L'","L2","U","U'","U2","D","D'","D2","F","F'","F2","B","B'","B2"]
scramblespyraminx = ["R","R'","R2","L","L'","L2","U","U'","U2","B","B'","B2","l","l'","r","r'","u","u'","b","b'"]
scramblesivy = ["R","R'","L","L'","U","U'"]
scramblesskewb = ["R","R'","R2","L","L'","L2","U","U'","U2","B","B'","B2","l","l'","r","r'","u","u'","b","b'"]
that = 'empty'
said = 'empty'
num = 20
add = 20

while True:
print('What kind of Rubik\'s cube do you want to scramble?')
print('1. 3x3x3')
print('2. 2x2x2')
print('3. Pyraminx')
print('4. Ivy cube')
which = input('-')
if which == '1':
said = '3x3x3'
new = scrambles3x3.copy()
add = 20
break
elif which == '2':
said = '2x2x2'
new = scrambles2x2.copy()
add = 15
break
elif which == '3':
said = 'Pyraminx'
new = scramblespyraminx.copy()
add = 15
break
elif which == '4':
said = 'Ivy cube'
new = scramblesivy.copy()
add = 15
break
elif which == '5':
said = 'Skewb'
new = scramblesskewb.copy()
add = 15
break
else:
print('Invalid answer')

os.system('clear')

while True:
num = add
for i in range(num):
this = random.choice(new)
if this == that:
num += 1
continue
that = this
sys.stdout.write(this + ' ')
sys.stdout.flush()
print('\n\n')
input(f'{said} scramble')
os.system('clear')
this = 'empty'
this has a couple errors and I hoping you can fix them

TheCheeseCoder (65)

@RhinoRunner

also I'm going making a website for cubers. This scramble gen is really good, so am I allowed to use the code?

I'll put u in the credits

Bunnytoes (165)

this is really cool I average about 7 seconds for 2x2 and can solve 3x3 (in a minute)and skewb in about 15 seconds

RhinoRunner (864)

@Bunnytoes nice, my 2x2 record is 9 seconds, 3x3 is 37 seconds, and skewb is 23 seconds.