ChatGPT Nails Code Golf with a Beautifully Elegant One-Liner for Ordinals
IgorBrigadir · x · 2026-08-12
While testing ChatGPT, a developer discovered that it generated a piece of code golf (minimalist code) art for appending English ordinal suffixes (e.g., 1st, 2nd, 3rd) to numbers:
O=lambda n:f"{n}{'tsnrhtdd'[(n//10%10!=1)(n%10<4)n%10::4]}"
The author was blown away by the absolute beauty of this solution. The replies sparked a discussion on whether AI could generate a system to create compound words where a sequence of letter removals yields a desired message.
Related event: ChatGPT Impresses Developers with Elegant Code Golf Solutions(2 posts)→
More from coding & agent
- Berkeley Talks on AI Agents: Harness and Skill Engineering Becoming a Science — seanwbren · 2026-08-12
- Build High-Fidelity Video Scenes for Under $2 Using Code Skeletons and Video Models — mattshumer_ · 2026-08-12
- A Minimalist AI Coding Workflow: Auditing Sentry Instrumentation via Codex — zeeg · 2026-08-12
- How I Orchestrate 19 AI Agents Across 86 Data Sources to Generate Sales Intelligence Reports — Active-Ad9071 · 2026-08-12
- Serverless Framework Introduces Stateless MCP Server Deployment — DavidWells · 2026-08-12
- Stop Hoarding Agents: Why a Structured 4-Agent Setup Beats 20 in Parallel — PrajwalTomar_ · 2026-08-12