The reasoning came from looking at the original discussion from when the exercise was first implemented and it looks like it was always designed as a perfect square exercise. These is a specific point about all the tests being perfect squares and all the expected output being whole numbers, so I thought it may be helpful to mention.
Looks like the author intended to implement a more generalized exercise, but I don’t know if this ever got anywhere.
Also, as far as I’m aware, there isn’t a distinction in terms of the actual math, between perfect and non-perfect squares. However, perfect squares are easier to use to explain the concept since most people can do napkin math and work with whole numbers easier than with floating point numbers. I feel that this would fall into the lying-to-children type of simplification.
True, the usual algorithms make no distinction about the type of the input. But that’s exactly why imposing an extra restriction would artificially increase the difficulty—people would get confused about how to create an algorithm that works with perfect squares. It makes the problem sound more difficult than it really is, and we already know that it’s a difficult problem for most.
I would also like to point out that a major issue is the inclusion of those wiki links regarding root calculation methods. Everyone will likely freeze if they’re presented with an endless list of incomprehensible math. It’s like throwing someone into the middle of the ocean and expecting them to find their way to shore.
I believe we’d get more value from the exercise if the focus is on implementing a specific algorithm.
My view is that the specifications should state that only an integer approximation to the square root is required in the result, and leave it to the students to determine whether they only wish to handle perfect square inputs which is sufficient for the tests.
Hmm. I chose to implement Heron’s Method with a log base 2 initial estimate using the bit_length() builtin, but there are also several simple integer algorithms on the Wikipedia page for Integer square root and I think we should be happy for students to consider the linear and binary search algorithms which may be easier to understand.
Okay so how about changing the bit about perfect squares to this:
And instead of relying on the wiki links, we can also add an explanation of a couple of algorithms, or links to such explanations. The wiki links can stay as a sort of ‘learn more’ section for the ones that are curious.
@xanni - Would you like to draft a new description?
You can use my suggestion as a base (in case we all agree that works) and add the paragraph about different algorithms, as well as take care of the links in the ‘learn more’ section.