Cards Shuffling

Back to Problem Solutions forum

Curio_Amigo     2020-10-30 08:18:42

Hello Folks!!!

I've gotten stuck with the problem #45. I've had revised all the code but couldn't be able to find the error.

Looking forward for help!

Cruio_Amigo

crydolphin666     2020-10-30 08:53:09

Use this for swapping elements in lists:

arr[i], arr[j] = arr[j], arr[i]

Also I have few comments to your code:
1. You don't have to check this if dados[k] >= 52: because any integer less than 52 by modulo 52 is going to be exact this integer.
2. This string:

return f'{[k for k in cards]}'.replace('[', '').replace(']', '').replace(',', '').replace("'", '')

Please read about join().
Or you can use unpacking operation for iterable sequences. It looks like print(*array)

a.kirdun     2020-12-10 15:53:29

I am do not understand whats wrong. may be here?

import random
    for i in range(52):
    j = int(random.random()*52)+1
    arr_of_cards[i] , arr_of_cards[j] = arr_of_cards[j], arr_of_cards[i]
risalahqolbu859     2022-10-06 09:35:39

i dont understand about the integer number in the input data, what should we do with them?

zelevin     2022-10-06 13:48:34

The integers in the input are the random numbers you are supposed to use instead of calling random.random(). How else would the checker know you've shuffled the cards correctly?

Please login and solve 5 problems to be able to post at forum