Card Shuffling (task 45)

Back to Problem Solutions forum

chandan_t     2015-09-21 10:18:38

What's the meaning of following (I think, I'm missing something):

"You will be given the sequence of non-negative integer random numbers - if they are greater than necessary, trim them to required range by taking modulo 52, like in the Double Dice Roll task."

Is it (givenRandomNumber%52) for random index generation for swapping or some thing else? Any clarification appreciated. Thanks.

Guy Gervais     2015-09-21 10:52:02
User avatar

Yes, if you have numbers > 52, you get them back in range by using "number modulo 52".

Christopher Matthews     2015-09-21 15:54:59

Modular arithmetic is something that every programmer should understand, as it is useful in a myriad of situations. I highly recommend becoming familiar with it. I would highly suggest the Code Abbey Wiki on Modular Arithmetic as a good starting point.

-- Christopher P. Matthews

chandan_t     2015-09-22 09:02:32

Thanks Guy and Christopher :)

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