adrianliaw / PyCuber

Rubik's Cube solver in Python
MIT License
195 stars 46 forks source link

Added __str__ implementation of color characters #15

Closed awwong1 closed 8 years ago

awwong1 commented 8 years ago

Added a string representation of the cube as output for Cubie and Cube str methods.

import pycuber as pc
# Create a Cube object
mycube = pc.Cube()

# Randomizing
rand_alg = pc.Formula().random()
mycube(rand_alg)

print(mycube)
print(repr(mycube))

Output of print(mycube):

         [g][y][o]
         [b][y][r]
         [g][g][o]
[w][o][y][r][r][y][g][b][g][w][b][r]
[y][r][w][b][g][o][g][o][w][g][b][g]
[y][r][r][w][o][y][b][r][w][o][w][b]
         [b][y][o]
         [y][w][w]
         [r][o][b]

To get the old functionality back of printing the actual colors to terminal, use print(repr(mycube))

adrianliaw commented 8 years ago

Thanks! @awwong1