As mentioned in @rolfl comment. What this program does is that it "resequences the cards using a fixed system and count the number of times the resequencing happens before the output is the same as the input."
I was wondering how I could make this program faster or perhaps use less memory. I thought about using
dictionaries instead of
lists as they have faster look ups. I'm not sure how to decrease the memory size of this program.
num_cards = input("Please enter the number of cards in the deck: ") def num_of_round(num_cards): rounds = 0 orig_order = range(1,num_cards + 1) card_list = list(orig_order) table_list =  while 1: while len(card_list) > 0: table_list.append(card_list) # STEP 1: add top card to table card_list.remove(card_list) # remove top card from deck if len(card_list) == 0: break card_list.append(card_list) # STEP 2: after removal of card, put top card on bottom of deck card_list.remove(card_list) # update ordering of deck rounds += 1 # a round has passed table_list.reverse() card_list, table_list = table_list, card_list if card_list == orig_order: break print rounds num_of_round(num_cards)