Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The square root problem needs to be improved #967

Closed
Ashvith10 opened this issue Apr 2, 2024 · 4 comments
Closed

The square root problem needs to be improved #967

Ashvith10 opened this issue Apr 2, 2024 · 4 comments

Comments

@Ashvith10
Copy link
Contributor

Ashvith10 commented Apr 2, 2024

Here are a few ideas I have in my mind:

  • Explicitly mention to not use the in-built math library:
    Because that simply defeats the purpose of this question. Learners should be using either the Babylonian, Bakhshali, or any other methods out there. The two methods that I have in mind - the entire math library be disabled by removing the -lm flag, or that sqrt() be overridden, instead generating random value.

  • Square root of a natural number is not always a natural number:
    The test case for the exercises are a bit misleading, because it assumes that the parameter will always be a perfect square, which isn't always the the case. Take for example, 5, whose root is 2.2360679775. Therefore, the return type should be of type float or double, as opposed to uint16_t.

  • Raise the difficulty to hard (optional):
    Having to craft your own formula using seed estimate and a formula of their choice (Babylonian, Bakshali, etc) is a little bit daunting for beginners, and in my opinion, beyond the skills required for medium difficulty questions.

@wolf99
Copy link
Contributor

wolf99 commented Apr 2, 2024

IIRC the intent of using uint16_t was to restrict the output to natural numbers so as to make the algorithm more simple.

The reasoning being that these are programming exercises rather than math exercises. In most real cases a programmer would simply use the library function.

We wanted something that would exercise the student, but not something that presents too high a barrier of entry.

Removing the -lm from the makefile is a good suggestion!

@ryanplusplus
Copy link
Member

The description and test cases come from the upstream problem specifications repo. I agree that removing -lm is a good track-specific reminder that a library function shouldn't be used.

@Ashvith10
Copy link
Contributor Author

@wolf99 and @ryanplusplus thank you for your response. Since the intent is to keep algorithms more simple, and solutions like brute-force are also equally acceptable, how about adding minor improvements to the description from the problem specification repository? If we let the learners know that the arguments will always be perfect squares, and therefore, they should not have to worry about the answer being non-integer rational numbers, this would lower the cognitive load for most students, who will jump on using complex techniques.

@wolf99
Copy link
Contributor

wolf99 commented Apr 2, 2024

I'm confused:

from the problem specification repository

The description on this track already matches the one in the problem-specifications repository

What is it that should change in this track?

If it is the problem specification that you think should change, then this issue needs to be raised there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants