Samsara Interview Question

write a method to shuffle the deck of cards

Interview Answer

Anonymous

Sep 26, 2018

def shuffle(self): n=len(self.cards) for i in range(n): r_index=randint(i,n-1) self.cards[r_index],self.cards[i]=self.cards[i],self.cards[r_index]

2