Cardchoose: a 12-line, provably fair no-retry algorithm for sampling without replacement
NathanpmYoung · x · 2026-10-26
Developer ciphergoth released the sansreplace repo tackling a deceptively subtle problem: dealing 5 cards from a 52-card deck so every hand is equally likely.
- The core Cardchoose algorithm is only a dozen lines: no retries, no extra memory, and provably fair
- The repo implements twelve sampling-without-replacement algorithms with Python, C++, and Rust implementations plus comparison docs and prior-art survey
- Apache-2.0 licensed
More from coding & agent
- Multi-agent setups bring no gains unless the model is specifically trained for them — xiaosun86 · 2026-10-26
- 5-layer agent memory setup: Mem0 cuts tokens 93%, Snowflake ontology lifts accuracy 20% — Arindam_1729 · 2026-10-26
- Skills written entirely by the model are useless, and stacking skills taxes agent context — HamelHusain · 2026-10-26
- Grok Bot hands-on: auto-logs hundreds of tasks to Linear and runs scheduled security checks — koltregaskes · 2026-10-26
- agent-saifu: an MCP server that gives AI agents their own isolated DeFi wallets — DecisiveCS · 2026-10-26
- GigaMail ships three MCP security patches against indirect prompt injection leaks — Soft-Lie-434 · 2026-10-26