logoalt Hacker News

Klondike Solitaire game for curses in 5k of C

68 pointsby nanochesslast Monday at 7:08 PM7 commentsview on HN

Comments

QuaternionsBhoptoday at 4:47 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.

baudauxtoday at 6:01 AM

I put csol in https://exaequos.com:

https://github.com/nielssp/csol

Type: /usr/games/csol in the terminal (or find solitaire)

userbinatortoday at 4:27 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.

show 1 reply
mgc8today at 6:23 AM

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

ares623today at 4:15 AM

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

show 1 reply