exercism / lua

Exercism exercises in Lua.
https://exercism.org/tracks/lua
MIT License
40 stars 57 forks source link

Square Root: the exercise is too cheesable (and/or confusing?) #508

Open rudzik8 opened 1 week ago

rudzik8 commented 1 week ago

As in, it's too easy to cheese your way through it, without actually solving it.

Let's consider the top 5 solutions to this exercise, by most submitted:

image

Sorted by group:

  1. Just using standard math.sqrt. 29 people submitted it. It's either trying to be funny, or being lazy, or just misunderstanding the exercise. Either way, submitting such a solution doesn't help anybody, including the student. It works and it's valid, but IMO it's not a solution.
  2. Raising the radicand to the power of 1/2. That's better, but still. Doesn't really teach you anything. It works and it's valid, but again, not a solution.
  3. Looping through all natural numbers until you stumble upon a square root of the radicand. I think it's obvious that this solution would lead to an infinite loop if a floating point value was passed into it. It works but it's invalid, and obviously not a solution.
  4. Using binary search. Now, this is pretty creative. Binary search is introduced a few exercises prior to that, which means that you don't actually learn something new with this, but out of the other top 5, this is great (and has also been mentored). It works and is valid, and definitely is a solution.

Suggestions

  1. Add floating point values to the test, as well as natural numbers that aren't squares (e.g. 5, 12, 888). This would make most of the invalid but currently working solutions fail the test. However, it could also block a lot of perfectly valid solutions. See t/12815.
  2. Make the instructions more verbose. Specifically, discuss some of the methods that can be used to calculate square roots, show some equations to go off of, etc. The Wikipedia article linked certainly is helpful, but some people might get confused by this.
  3. Mention in the instructions that using math.sqrt isn't welcome. Usage of standard library functions instead of writing your own code is already discouraged in the instructions for some other exercises. It would certainly be nice to see that under Square Root too.
keiravillekode commented 1 week ago

The practice exercises are based on problem-specifications shared across all tracks (programming languages).

If there are Lua-specific notes, we can append to the instructions; we do this for resistor-color

As your suggestions are not Lua-specific, the best place to discuss any proposed changes to problem-specifications is the forum.

rudzik8 commented 1 week ago

Thanks for the hint!

If there are Lua-specific notes, we can append to the instructions; we do this for resistor-color

Suggestions 1 and 3 certainly fall into the category of being specific to this track.

rudzik8 commented 1 week ago

Related: https://github.com/exercism/problem-specifications/issues/2415