Why is the Allergies Solution Like This?

I am very confused why the last test in the “Allergies” Exercise does not contain “Peanuts”.

fn scores_over_255_do_not_trigger_false_positives() {
    let expected = &[
    let allergies = Allergies::new(509).allergies();

    compare_allergy_vectors(expected, &allergies);

It has everything except Peanuts…

In this solution, all I’m doing is checking that the allergen exists and is not equal to zero… huh? Shouldn’t I be decrementing the allergen points from the score or something? What is the relationship here between score and allergens? I though if the score is greater than the allergen value then the person is allergic…

pub struct Allergies {
    score: u8,
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Allergen {
    Eggs = 1,
    Peanuts = 2,
    Shellfish = 4,
    Strawberries = 8,
    Tomatoes = 16,
    Chocolate = 32,
    Pollen = 64,
    Cats = 128,
impl Allergies {
    pub fn new(score: u32) -> Self {
        Self { score: score as u8 }
    pub fn is_allergic_to(&self, allergen: &Allergen) -> bool {
        self.score & *allergen as u8 != 0
    pub fn allergies(&self) -> Vec<Allergen> {
        let all_allergens = vec![
            .filter(|allergen| self.is_allergic_to(allergen))

Also, if my solution passes all tests why can’t I share it?

And finally I am posting here asking for help because the lame points system will not let me get any more mentoring… :disappointed:

1 Like

I am having trouble trying to understand what you are asking.

Is your solution relevant to your question? Are you asking one question or two? Are you asking to be mentored?

You can only publish solutions to exercises that you have marked as Completed.

Do you have 3 active mentoring sessions, or have some of them already concluded?

Not very nice to call Chesterton’s fence ‘lame’.

1 Like

The allergies exercise is related to the concept of a bit set.

The instructions also contain:

Note: a given score may include allergens not listed above (i.e. allergens that score 256, 512, 1024, etc.). Your program should ignore those components of the score. For example, if the allergy score is 257, your program should only report the eggs (1) allergy.

The test case you mention is for the score 509. 509 in decimal is 111111101 in binary. So the bit for Peanuts is not set, but the bits for the other tested allergens are. Removing the most significant bit, we have the decimal score of 253 (binary 111111101), which should produce the same result.

Does that help?

I still don’t understand what the binary representation has to do with anything. Nothing in the exercise instructions says anything about converting everything to binary…

I thought if the score is greater than the allergen value then the person is allergic…

This is where you’re confused. Take the instruction: “So if Tom is allergic to peanuts and chocolate, he gets a score of 34.” Each number is a flag and you need to work out what flags are in there.

Away from the exercise, please moderate your tone. Describing things as “lame” is not productive, empathetic or kind, and therefore not appropriate for this forum.


Perhaps not explicitly, but the instructions do say:

The list of items (and their value) that were tested are:

  • eggs (1)
  • peanuts (2)
  • shellfish (4)
  • strawberries (8)
  • tomatoes (16)
  • chocolate (32)
  • pollen (64)
  • cats (128)

So if Tom is allergic to peanuts and chocolate, he gets a score of 34.

The sum of the values of the allergens equals to the score of the person. In other words, from the score you need to find which allergens add up to that score. So it’s not sufficient to just check if the score is greater than the allergen value. That’s where the binary representation comes in. Each number (the score in our case) can be uniquely written as a sum of powers of two (the allergen values in our case) and from these powers you can immediately find its binary representation. The representation will have the bits that correspond to those powers equal to 1 and all the rest will be 0.

So converting to binary is one way to solve the problem, but there are other simpler approaches too.

Thanks. Now I understand that this is actually a type of “binary riddle” rather than anything that actually has to do with allergies and science. I have no clue how any student is supposed to figure that out from the directions though. :man_shrugging:

@iHiD Sorry, what is the “empathetic and kind” way to say that this “feature” makes the whole experience much worse?

Forcing people to mentor others who don’t want to will 1) lower the quality of mentoring and 2) prevent people who want to be mentored from getting it.

This seems completely counterproductive given that the whole point of the site is get more people learning and getting mentored…

What happened to the plan for having automated ai mentoring that instantly gives you feedback right when your solution is submitted? That’s what you guys should really be working on!

what is the “empathetic and kind” way to say that this “feature” makes the whole experience much worse?

Taking 5 minutes out to ask why it might exist first and then acknowledge those reasons and explain the downsides that we might not have considered. ie, don’t complain or use words like “lame” - have an adult conversation.

Forcing people to mentor others who don’t want to…

I have no idea what you mean by this, or how it’s relevant to limiting you to only having 5 open mentoring sessions at once.

What happened to the plan for having automated ai mentoring that instantly gives you feedback right when your solution is submitted?

We have given out 880,000 pieces of automated feedback.

That’s what you guys should really be working on!

While you’re entitled to your opinion, stating it like this is just entitled.

A nicer way of putting this is «I had trouble figuring this out from the instructions alone, and fear other people might as well.»

~2649 people completed this exercise on the Rust track before you, and many thousands more on the other tracks as well.

The quotation marks make this sound dismissive, and the «much worse» suggests you think the experience was bad already.

You think forcing people is a ridiculous measure. Do you honestly expect Exercism’s creators to think otherwise? This is a hint! You have probably misunderstood the situation, and people aren’t acutally being forced.

The way to resolve such confusion is not to go arround accusing people of doing stupid things, but to ask how your impression is wrong (because you should reckon it probably is).

A nicer way of putting this would be:

Previously I received automated feedback on my submitted solutions. However, on my most recent submissions I did not receive any. What might be the cause of this?

Perhaps even throw in a «I really liked this automatic feedback» somewhere.

Exercism is run mostly by volunteers, who could do with less of this.


All I’m saying is that I submitted a solution and was confronted with this strange and confusing page for the first time. On this page I am left scratching my head and left wondering:

  1. what in the world are “mentoring slots”?

  2. why are all my mentoring slots unavailable and how do make these slots available again?

  3. what is the purpose of giving each person limited slots in the first place?

I think links to those things on this page would be a good idea. Instead there is only one link to a page explaining that mentoring now works like the communist china reputation system where only the highest reputation people get the full exercism experience. :confused:

@iHiD where is the automated mentoring for my rust allergies submission? I don’t see any feedback anywhere. I don’t even see a way to share my solution with anyone!!

@JimLynchCodes I’ve silenced your account for a week. If you’d like to reconsider the way you’re engaging with the community, then you’ll be welcome to post again here in a week and we can continue the conversation in a productive manner.

But I’m not willing to have this tone or rudeness within Exercism.

I believe you intended to say this, but you weren’t actually saying this previously. But now you are, and this is helpful. Thanks :+1:

I totally agree this page could use quite a bit of clarification. It seems there is plenty space for explanation.

Protecting the mentor pool from being overburdened by large numbers of (typically low-effort) requests from the same student. Also: encouraging students to finish their mentoring sessions. Possibly among other things, this improves mentors’ well-being.

Maybe this measure is out-dated. I wouldn’t know; perhaps @iHiD does.

This might be technically true but is morally false. Almost everyone gets almost all features. Only supermentors and such gain access to some extra thingies unrelated to learning.

Perhaps automatic feedback is not (yet) implemented on the Rust track.

You can only publish solutions to exercises you have marked as Completed.

For anyone else reading this in the future, each person can be mentored a limited amount of times at once on a track. This is to prevent certain students from spamming mentors with multiple requests, thus blocking the queues for other students and also not respecting that they’re getting mentors’ time for free. The more you contribute to Exercism (ie the higher reputation you have) the more simultaneous sessions you can have at once.

I believe it is entirely reasonable that in a closed eco-system that those who give more should also receive more. I also am aware that often the people who need things the most are both cash-limited (thus Exercism being free) and time-limited (thus being able to get everything educational in Exercism even if you don’t contribute). So we balance that very carefully. But from memory, the only features that you get as a high-rep user are new ways to contribute and a couple of extra simultaneous mentoring slots.

Finally, some people do not respect the time and effort that people put into Exercism and act in an entitled manner towards the platform and its volunteers. These people don’t act in the spirit of Exercism, and we do not tolerate that behaviour.