Perfect Riffle Shuffle II: String Formatting

My last post on riffle shuffles features a table displaying the results of eight successive perfect out riffle shuffles. I think you’ll agree with me that the formatting is rather ugly. At the time of writing, I could not think of an elegant way to display the order of cards in a deck after a shuffle vertically using Python. I now believe that I have a solution.
Here is the code:

import string

#Label the riffle_shuffle function by 'f'

#Initialize an empty list to contain the iterated shuffled decks
decks = []
deck = range(1,53)

#Shuffle the deck 8 times
for i in range(0,8):
for j in range(0,53):
    if j == 0:
        for i in range(0,8):
            if i < 7:
                print'Shuffles = ' + str(i+1),12),
                print'Shuffles = ' + str(i+1),12)
        for i in range(0,8):
            if i < 7:
                print[i][j-1]),12) + '\n'


This entry was posted in Progamming, Python. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s