alt.hn

6/8/2026 at 7:08:12 PM

Klondike Solitaire game for curses in 5k of C

https://nanochess.org/klondike_in_c.html

by nanochess

6/11/2026 at 4:47:32 AM

I recently wrote klondike in Rust after getting frustrated with bugs in my friend's LLM-written version. I highly recommend it as a recreational programming exercise, the first 4 hour blitz filling out the types was a blast. Later, trying to make as many invalid moves unexpressable by the given types as possible was a fun challenge. I ended up with a 232 byte struct for the board state with all values stack-allocated. The only way to make it considerably smaller would probably be to encode card permutations.

by QuaternionsBhop

6/11/2026 at 4:27:14 AM

Everyone knows that the != operator is a surplus of the C language, use only the minus operator.

It's notable that on most CPUs, the comparison instruction is equivalent to a subtraction but without writing the actual result.

by userbinator

6/11/2026 at 8:00:50 AM

Wouldn't XOR or something be much quicker than all the steps involved in subtraction?

by badc0ffee

6/11/2026 at 8:21:54 AM

They’ve both had the exact same cost (both throughput and latency) on just about any ALU designed in the last several decades. There are no separate steps involved in the function of a full adder.

by Sharlin

6/11/2026 at 4:15:22 AM

I thought games need GPU acceleration and React? How is this possible?

by ares623

6/11/2026 at 4:53:17 AM

Wait, he didn’t have to import 237 NPM packages?

by acheron

6/11/2026 at 9:15:35 AM

Exactly! Can't even imagine how this runs?

Smirks and shruggs...

by indianmouse

6/11/2026 at 9:48:51 AM

Well, hmm. well.. how many jira tickets were needed?

by greenbit

6/11/2026 at 10:28:35 AM

there are terminal emulators that are GPU accelerated to be fair, so in a sense this game would get GPU accelerated?

by asimovDev

6/11/2026 at 10:13:42 AM

My god this is insane! You'll steal a lot of hearts

by saurabhsinghvi

6/11/2026 at 1:29:24 PM

Truly the biggest prize of the IOCCC is getting your name listed next to geniuses like the author of nanochess.

by yalue

6/11/2026 at 6:23:10 AM

This is seriously cool, and as a bonus reminds me to brush up on my C knowledge to finally submit an IOCCC entry...

by mgc8

6/11/2026 at 10:08:08 AM

That source code is melting my brain

by Hugsbox

6/11/2026 at 1:59:19 PM

undo is always where these tiny games stop being tiny

by patdoli

6/11/2026 at 9:20:28 AM

Fantastic read and article.

As an ardent follower of IOCCC since ages (where I learnt a trick or two during the initial C days around late 90s) this is seriously cool!

Many may not even appreciate the power of C! Becoz hardly it is getting taught and used nowadays. People who know knows it better. The laziness and wrappers have taken over the programming world and now AI is taking it to another level.

In near future, I guess people might even forget to code! Where to optimize and obfuscate then? Skilled ones would need to be preserved with awe!

Need to document them (not as a training material for AI for sure!), but somewhere else where it could be learnt by the one who needs it! Privately!

Having it on the internet is definitely prone to stealing / misusing it in the name of fair use policy.

by indianmouse