News for hackers. Stuff that matters.
Re:Solitaire with text-based interface in C by zokier on Sunday July 12, 2020 @06:03PM (#23815145)
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/ca...

Re:Solitaire with text-based interface in C by fao_ on Sunday July 12, 2020 @06:18PM (#23815235)
> 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.