top | item 10165783 (no title) DatBear | 10 years ago Why not just i % 4? discuss order hn newest novaleaf|10 years ago that would alternate the suit for each card, and all the aces would be the same suit, etc. epyjao|10 years ago If you also take the cards modulo 13 for their face, this approach works.4 and 13 are relatively prime, so each number between 1 and 52 can be uniquely represented by the function (x) -> (x%13, x%4). unknown|10 years ago [deleted] DatBear|10 years ago Yes, obviously it's not a drop in replacement as the behavior is different, but it does the same thing, giving you a number from 0 to 3 based on the card number. Pairing it with i%13 works just fine.
novaleaf|10 years ago that would alternate the suit for each card, and all the aces would be the same suit, etc. epyjao|10 years ago If you also take the cards modulo 13 for their face, this approach works.4 and 13 are relatively prime, so each number between 1 and 52 can be uniquely represented by the function (x) -> (x%13, x%4). unknown|10 years ago [deleted] DatBear|10 years ago Yes, obviously it's not a drop in replacement as the behavior is different, but it does the same thing, giving you a number from 0 to 3 based on the card number. Pairing it with i%13 works just fine.
epyjao|10 years ago If you also take the cards modulo 13 for their face, this approach works.4 and 13 are relatively prime, so each number between 1 and 52 can be uniquely represented by the function (x) -> (x%13, x%4).
DatBear|10 years ago Yes, obviously it's not a drop in replacement as the behavior is different, but it does the same thing, giving you a number from 0 to 3 based on the card number. Pairing it with i%13 works just fine.
novaleaf|10 years ago
epyjao|10 years ago
4 and 13 are relatively prime, so each number between 1 and 52 can be uniquely represented by the function (x) -> (x%13, x%4).
unknown|10 years ago
[deleted]
DatBear|10 years ago