[48in24 Exercise] [03-19] Allergies

This issue is a discussion for contributors to collaborate in getting ready to be featured in 48in24. Please refer to this forum topic for more info.

We will be featuring Allergies from Mar 19 onwards.

Staff jobs

These are things for Erik/Jeremy to do:

  • ☐ Check/update exercise in Problem Specifications
  • :ballot_box_with_check: Create + schedule video

Community jobs

For each track:

  • Implement Allergies
  • Add approaches (and an approaches introduction!) for each idiomatic or interesting/educational approach.
  • Add video walkthroughs (record yourself solving and digging deeper into the exercise).
  • Highlight up to 16 different featured exercises (coming soon)

Existing Approaches

You can use these as the basis for approaches on your own tracks. Feel free to copy/paste/reuse/rewrite/etc as you see fit! Maybe ask ChatGPT to translate to your programming language.

  • vec-on-new (rust)
  • vec-when-requested (rust)

Track Statuses

You can see an overview of which tracks have implemented the exercise at the #48in24 implementation status page.

I’ll take care of Ballerina, CFML, CoffeeScript, and D.


I think Elm is a featured language for Allergies, so I will try and add the approaches. I might not have enough time to get it done though …


For this exercise’s video, I currently have these solutions and taling points. If you know more or better versions of these, let me know.

  1. Gleam: type for allergen and use pattern matching, list uses allergic_to

Custom type for allergen and use pattern matching to assign type

  1. JavaScript: dictionary for mapping

Use a dictionary for mapping allergens to their bit scores

  1. Ruby: index determines allergen value

Have the index determine the allergen value

  1. Clojure: bit test function and hash set, allergic_to uses list

Use a function to test if bit is set and allergic_to reuses list of allergens

  1. C#: define enum as a flags enum (easy testing of bits)

Also show other ways in which to define the bit masks

  1. Nim: automatically convert number to set of enum

Use cast to convert a number of an enum set

  1. Python: iteratively subtract enum values

Subtract the enum values in reverse

I’ve added the approaches for Elm, PR here if people are interested:


The Raku documentation has an example well suited to this exercise:


My solution has borrowed from this. The enums are given the appropriate values using a lazy infinite sequence. An ACCEPTS method has been mixed in with the enum and can be called on any of the enum values to check the score matches. The smartmatch operator is a shortcut to ACCEPTS.

1 Like

Adding to the V track

1 Like

Since Pyret is live, I guess I should add allergies there.

1 Like

lol - the pain of a new track now needing all the 48in24 exercises :grin:

1 Like

Happily, the sqlite track is also new, complete with Allergies already :clap:.

I’ll watch with interest to see if anyone tries to add Zebra Puzzle to that (I’m not volunteering).

1 Like

And one without bitwise operators to boot. I’m about to learn some math for the first time in two decades. :sweat_smile:

1 Like

Catching up on Red exercises to port :slight_smile:

1 Like