Advertisement
PowerCell46

Faro shuffle Python

Dec 27th, 2022
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import math
  2.  
  3. cards = str(input())
  4. cards = cards.split()
  5. number_of_shuffles = int(input())
  6.  
  7. while True:
  8.     number_of_shuffles -= 1
  9.     if number_of_shuffles == -1:
  10.         break
  11.  
  12.     middle_index = len(cards) / 2
  13.     middle_index = math.trunc(middle_index)
  14.  
  15.     first_half = cards[:middle_index].copy()
  16.     second_half = cards[middle_index:].copy()
  17.     cards = []
  18.     index = 0
  19.     while len(first_half) > 0 and len(second_half) > 0:
  20.         current_fist_card = first_half.pop(index)
  21.         current_second_card = second_half.pop(index)
  22.         cards.append(current_fist_card)
  23.         cards.append(current_second_card)
  24.  
  25. print(cards)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement