Bit Shifting, Bitwise Comparisons and other Binary Number Magic (Solving Allergies on Exercism)

Опубликовано: 05 Февраль 2026
на канале: Exercism
3,198
85

In this video, we explore 8 different approaches to solving Allergies, focussing on Binary numbers and techniques like bitshifting and bitwise comparison. We look at solutions from Clojure, Ruby, JavaScript, C#, Nim, Python, Gleam and Erlang!

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/allergies
Join #48in24 at: https://exercism.org/challenges/48in24


Featured Solutions:
https://exercism.org/tracks/clojure/e...
https://exercism.org/tracks/ruby/exer...
https://exercism.org/tracks/javascrip...
https://exercism.org/tracks/csharp/ex...
https://exercism.org/tracks/nim/exerc...
https://exercism.org/tracks/nim/exerc...
https://exercism.org/tracks/gleam/exe...
https://exercism.org/tracks/erlang/ex...

Timestamps:
00:00:00 Introduction
00:01:04 Clojure: series of boolean expressions, built-in function to test for bit set
00:03:48 C#: define flags enum with binary allergen scores to allow easy testing of bits set
00:12:39 Ruby: dictionary to map allergen to its score
00:17:25 JavaScript: use bit shifting and index to map allergen to its score
00:20:11 Nim: define allergen enum and cast score to set of matching enum values
00:21:56 Python: pre-calculate the allergies list in constructor
00:24:46 Gleam: pattern matching and higher-order function
00:27:49 Erlang: recursion, pattern matching and greater than comparisons
00:33:44 Conclusion