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

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

2.550 Lượt nghe
Bit Shifting, Bitwise Comparisons and other Binary Number Magic (Solving Allergies on Exercism)
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/exercises/allergies/solutions/amscotti - https://exercism.org/tracks/ruby/exercises/allergies/solutions/brodyf - https://exercism.org/tracks/javascript/exercises/allergies/solutions/ghjk - https://exercism.org/tracks/csharp/exercises/allergies/solutions/ErikSchierboom - https://exercism.org/tracks/nim/exercises/allergies/solutions/Rabidax - https://exercism.org/tracks/nim/exercises/allergies/solutions/Rabidax - https://exercism.org/tracks/gleam/exercises/allergies/solutions/Fryght - https://exercism.org/tracks/erlang/exercises/allergies/solutions/JordanAdams 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