3 ms·
I probably would have opted for the array representation instead of linked lists, but that is somewhat subjective thing. I do note that each card can be represe
by zokier 6y ago
I probably would have opted for the array representation instead of linked lists, but that is somewhat subjective thing. I do note that each card can be represented by single byte fairly easily (2 bits for suit, 4 bits for rank, 1 bit for revealed (maybe)), which would reduce memory consumption if that is concern. Thinking more of it, I think the whole board-state could be represented with 13+52 byte array, having markers between the cards to indicate different piles. Not that I'd recommend that approach unless you are extremely memory constrained, it probably would bit annoying to handle
fyi I noticed that your mallocz seems to reimplement calloc: https://pubs.opengroup.org/onlinepubs/009695399/functions/calloc.html https://pubs.opengroup.org/onlinepubs/009695399/functions/ca...
- fao_ 6y ago> I think the whole board-state could be represented with 13+52 byte array, having markers between the cards to indicate different piles. A multiple-gap buffer is more difficult to handle than a linked list, yeah.