Codeck

Not all characters can be encoded. The actual encoded message is

Encoded Message (Drag cards to change)

What's going on here?

A few years ago while playing cards, I had an idea. More like a question, really: could you encode a message in a deck of cards? Is that mathematically possible?

A few weeks ago, I realized hey, you can Google that sort of thing. Google lead me to a stack overflow article called Fast permutation -> number -> permutation mapping algorithms. That introduced me to the word I was looking for: Factorial number system, and the related concept of Lehmer codes, so I went straight to Wikipedia and began to figure out what I had gotten myself into. The good news was that mathematicians have studied this thing and come up with some great research.

Once I figured out how it was possible to encode a message in a deck of cards, I made this web app to demonstrate it was possible, and that brings us to what you're looking at now.

How long can the messages be?

That depends on two things: How many cards are in a deck, and how many letters are in your alphabet. Since there are fifty-two cards in a deck, there are 52! ≈ 8✖️1057 possible orders for a deck of cards. If your alphabet has 39 letters (26 proper letters, 10 digits, space, quote, and period), then you will need to be able to store 39l messages, where l is the maximum length of a message.

This gives us the following formula to solve for l:

52! ≥ 39l

This equation can be solved for l by asking Siri, "What's the log of 52 factorial divided by the log of 39?" The answer will be about 42.68, which rounds down to a maximum length of 42 characters, since it doesn't make sense to encode part of a character.

Why is it named Codeck?

A codec is a word for something that encodes and decodes messages, and I'm not one to pass up a good pun. Or a bad one, apparently.

How was this built?

The styles and code are my own, but I got a lot of help from a data visualization library called D3.js (not affiliated with this project). All the code I wrote is available on Github at Codeck.