samedi 5 novembre 2022

How do I create a random VECTOR

I'm completely new to Python, in fact the last time I knew any programming it was commodor-64 basic (apologies).

I'm trying to create random vectors in PYHON. The vector is 52 digits bit only containing 0 - 12 and the vector itself must not repeat. I tried this...

from random import randint
        vector = [randint(0, 12) for p in range(0, 52)]

...but I suspect (although it kind of does the job), I have no way of telling if it isn't repeating the full 52 digit vector at any point. I ran it for several hours and it generated over 44 million times but didn't match the number I wanted it to...I don't even know how many permitations there would be... I'm guessing 52! (51 x 50 x 49...etc) so 44 million is a drop in the (VERY BIG) ocean (my maths isn't up to that).

Or am I wasting my time?

Thanks folks

from random import randint
        vector = [randint(0, 12) for p in range(0, 52)]

I want to repeatedly create a 52 digit vector/matrix of numbers 0 - 12 with no repeat of whole vector (simulated deck of cards shuffle) in Python.




Aucun commentaire:

Enregistrer un commentaire