Generate large number of random card decks - NumPy

前端 未结 3 1433
臣服心动
臣服心动 2020-12-12 00:48

I need to generate a large number of random poker card decks. Speed is important so everything has to be in numpy matrix form.

I understand I can generate two cards

3条回答
  •  被撕碎了的回忆
    2020-12-12 00:53

    A another simple approach, slightly slower than @Holt best solution.

    def vectorized_app(N):
        u=np.random.randint(0,12*4,(2*N*103//100)).reshape(-1,2) # 3% more tries. 
        w=np.not_equal(*u.T) #selecting valid output, Two differents cards.
        return u[w][:N]
    

提交回复
热议问题