Tuesday, 1 October 2013

Store a playing cards deck in MySQL (single column)

Store a playing cards deck in MySQL (single column)

I'm doing a game with playing cards and have to store shuffled decks in
MySQL.
What is the most efficient way to store a deck of 52 cards in a single
column? And save/retrieve those using PHP.
I need 6 bits to represent a number from 0 to 52 and thus thought of
saving the deck as binary data but I've tried using PHP's pack function
without much luck. My best shot is saving a string of 104 characters (52
zero-padded integers) but that's far from optimal.
Thanks.

No comments:

Post a Comment