Probability Calculator test should be updated?

Tell us what’s happening:
Hi, this is not so much an ask for help as a suggestion and validation check that one of the tests on a project should be changed. The project I’m referring to is the probability calculator in the scientific computing with Python curriculum and the test is the second test (titled “test_hat_draw”).

The second part of the test asserts whether the contents of the Hat object have been updated after calling the “draw” method. I believe the intent of is to see if the student correctly followed the instruction “The balls should not go back into the hat during the draw”.

However it doesn’t say that the balls can’t go back in the hat after the draw and, by assuming the student doesn’t, the test now forces the student to reinstantiate the Hat object multiple times in the second part of the project when they are running multiple experiments.

While it’s not the biggest deal, I’m pointing this out as a source of frustration from the student’s POV and a suggestion of a way we might improve the curriculum and experience of students.

I’d be happy to suggest an update to the test but I wanted to see what other people think first.

Your code so far
The code I used for the draw method that returned the Hat’s contents to their original state after the drawing (and passed the rest of the tests):

def draw(self, num:int) -> [str]:
  if num >= len(self.contents):
    return self.contents
  dupecontents = copy.copy(self.contents)
  output:[str] = []
  for _ in range(num):
    ind = random.randint(0, len(self.contents) - 1)
    output.append(self.contents[ind])
    self.contents.pop(ind)
    self.contents = dupecontents
    return output

Challenge: Probability Calculator

Link to the challenge:

Not really? You can clone the entire hat before each experiment. You made a pretty complicated draw method but mine was much, much simpler.

You can clone the entire hat before each experiment.

That’s what I ended up doing to get all of the tests to pass. Still, cloning the hat before each experiment versus cloning the contents of the hat before a draw basically accomplish the same thing. Ideally, I don’t think the test should force you to do one over the other.

You made a pretty complicated draw method but mine was much, much simpler.

I’m not sure what this has to do with anything. Congrats? I’m talking about how to improve students’ experience on fCC, especially newbie programmers. From your LinkedIn you have multiple degrees in mathematics and many years of professional experience in software engineering so I don’t think it’s fair to assume others’ experience should reflect yours.

Stalking my LinkedIn and bringing that into this convo to argue your point is a bit strange. Please don’t.

I’m not trying to brag. I’m pointing out that rewriting the project to make students use your solution will make the project harder to finish rather than easier because your approach requires more complex code than the project requires currently.

The instructions aren’t perfect or as clear as I would prefer, but I think telling the students to use a new hat for each draw is easier for them to implement than telling them to make an additional method or logic for putting balls back.

First, your LinkedIn is right on your website which shows up when someone clicks your name so I wouldn’t call it “stalking.”

Second, if you go back and reread my original post, my suggestion was not rewrite the test to make students use my solution (or make it “harder” to finish), but to make the test more agnostic to either approach. Indeed, in my case, that would have made the project easier to finish because I had to go back and rewrite my code just to pass that specific test. Furthermore, from what I could tell, nowhere does it tell the students to use a new hat for each draw, that is assumed by the test.

Honestly, my original post was meant to be a way of possibly contributing to the curriculum in some small way and I’m pretty shocked by the immediate and conclusive pushback I received by an fCC moderator. That is not the reaction I was expecting and I really hope other hopeful contributors aren’t treated the same.

We can drop the discussion. I am almost sorry that I brought it up.

Sorry for misunderstanding, it really looked to me like you were advocating for requiring that the balls go back after the draw.

Because the number of replications in the last test isn’t big enough to push the percentage to the theoretical expected percentage, the order of the hat contents on every draw matters. But there are many different ways to interpret putting the balls back. I honestly think introducing this idea of replacement after a draw adds complexity because we would have to constrain how the balls are put back. And that’s just more code for the student to write than they currently need. That means more requirements and tests. It’s simpler to say that you use a new hat each time. If the instructions don’t say that a new hat should be used or that the hat needs to be reset between draws in the experiment, perhaps it should.

Side Note: ‘replacement’ has a specific meaning in this type of problem and using it in the way you are can cause confusion.

The thing is, as a student myself, who vaguely remember running into this issue and getting frustrated, I’m not so sure what you try to achieve.
Like, full disclosure, I looked at the forum to get an idea on how to deal with this issue, found someone mentioning a way to resolve this and implemented that.

Do I think this should be changed, made easier? Well… dunno? Is making it easier really the right approach for something that is meant to be challenging?

You identified an hard part, considered it an issue and offered a solution.
The thing is, you didn’t elaborate on “why is that an issue”? You just assumed it is because students have to work around it. But maybe that is intentional?
Yeah it didn’t say the balls cannot go back after the draw - but it also didn’t say they could.

1 Like

if the project is missing a point about the hat, it can be added in for sure. It is preferred to clear out the description than change project tests

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.