Socially Distant Coding Challenge: Share the Sequence of a Deck of Playing Cards optimally

If you stored the absolute value of the first card you would need 6 bits.

You could then use the next 5 bits to determine the position of the next card, using the last digit of the value before it to indicate whether you should add or subtract the next 5 bits from that position.

You could continue that until there are only 32 possible positions, meaning you need 4 bits to store the next set of values.

At 16 possible positions you can use 3 bits to store the next sets of values.

And so on, until there is one position remaining, which you don't need to store.

If I didn't screw my math up (I probably did), I think you could get away with 194 bits.

/r/programming Thread Parent Link - github.com