8 Ways to Solve Zebra Puzzle (feat. Genetic Algorithm!)

Опубликовано: 07 Февраль 2026
на канале: Exercism
3,005
84

We look at 8 different solutions to Exercism's Zebra Puzzle exercise. We look at a wide variety of solutions, starting with Prolog (the perfect exercise to showcase the language) and then some other interesting approaches include the AC-3 Algorithm and a Genetic Algorithm. We feature Kotlin, Python, Scala, Prolog, C, Elixir, Java and C#

Kick back and enjoy 75mins 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/zebra-...
Join #48in24 at: https://exercism.org/challenges/48in24

Featured solutions:
https://exercism.org/tracks/kotlin/ex...
https://exercism.org/tracks/python/ex...
https://exercism.org/tracks/scala/exe...
https://exercism.org/tracks/prolog/ex...
https://exercism.org/tracks/prolog/ex...
https://exercism.org/tracks/elixir/ex...
https://exercism.org/tracks/java/exer...
https://exercism.org/tracks/csharp/ex...

Timestamps:
00:00:00 Introduction
00:01:19 Kotlin: directly return answer
00:01:44 Prolog: logic-based pattern
00:09:15 C#: use generic algorithm
00:29:51 Python: pre ordered permutation values
00:36:53 C: use unsigned int to encode options and use bit manipulation
00:46:00 Scala: check only valid permutations
00:52:15 Elixir: mutate using rules via depth-first search
01:04:41 Java: use AC-3 algorithm
01:15:41 Conclusion