Understanding Randomness: 7 Ways to Solve D&D Character

Опубликовано: 07 Август 2026
на канале: Exercism
3,431
78

We look at 7 different solutions to Exercism's D&D Character exercise - exploring solutions using different approaches to randomness and metaprogramming in Kotlin, Nim, Racket, Tcl, Python, C++ and Haskell.

Kick back and enjoy 30mins of learning with Jeremy and Erik, then go solve the exercise in your favourite way on Exercism.

Solve the exercise at: https://exercism.org/exercises/dnd-ch...
Join #48in24 at: https://exercism.org/challenges/48in24

Links:
Tests we showed on GitHub: https://github.com/exercism/haskell/b...
"rand considered harmful":    • GoingNative 2013 rand Considered Harmful  

Featured solutions:
https://exercism.org/tracks/kotlin/ex...
https://exercism.org/tracks/nim/exerc...
https://exercism.org/tracks/racket/ex...
https://exercism.org/tracks/tcl/exerc...
https://exercism.org/tracks/python/ex...
https://exercism.org/tracks/cpp/exerc...
https://exercism.org/tracks/haskell/e...

Timestamps:
00:00:00 Introduction
00:00:53 Kotlin: assign fields directly, ability use random in range and sort + drop
00:05:13 Nim: seed random, explicit side-effects and use sum - min for ability score
00:13:52 Racket: create new character via plain function calls
00:17:51 Tcl: loop over all fields, separate procedure to roll die
00:22:44 Python: dynamically create fields
00:25:41 C++: ensure uniform distribution and keep track of min value
00:35:33 Haskell: define generators
00:44:37 Conclusion