Posting here because problem-specifications repo automatically closing all new issues.
At present there are no test cases which use negative integers for the ‘Is an Armstrong number’ exercise.
This wikipedia article, the same one referenced in the problem description, would seem to imply that Armstrong numbers can be negative.
If negative numbers are legal or not. Either way do the test cases need updating?
Any mathematicians out there with a definitive answer?
The article says they “can be extended” to negative numbers. Not that, “negative numbers are included”. The unit tests and the exercise don’t bother with negative values. The scope of the exercise is positive integers.
I don’t think there’s any need or reason to change anything. The purpose of the exercise isn’t to explore any and all extensions, or even uses/combinations of those values. The purpose of the exercise is to write code which efficiently and cleanly solves the problem in the limited scope the exercise handles. Broadly speaking, the scope of most things in life can be expanded; that doesn’t mean they should. The way exercises are scoped sets up the challenge and difficulty of the exercise. The scope shouldn’t be altered because it can be done; scopes should only be altered because there’s a very good reason to change the scope. If there’s a compelling reason to change the scope, then options for changing the scope become relevant.
That makes sense. Thanks for the prompt response.
Would it be worth just adding a note in the description saying “For this exercise, don’t worry about the possibility of negative armstrong numbers. Assume all inputs will be positive.”? Just to avoid any potential future questions and make it a bit more explicit to the learner?
That Wikipedia article talks about “signed-digit representation”, not signed numbers.
I had a hard time understanding the article about Signed-digit representation, but I guess an example would be Balanced Ternary which can represent all integers (positive and negative) with just three digits where one of them is negative.
But our armstrong-numbers exercise specifically deals with decimal digits which are all non-negative.
(If I misunderstood any of that please correct me, I like to learn more)
Of the participants in this thread up to now, I am probably the closest to being a ‘mathematician’.
It is not obvious to me how a negative integer might be considered an Armstrong number.
As neither Sieben (after research) nor I (at little more than a glance) understand the supposed extension, it seems safe to say that the exercise should not be extended to negative integers.
I’d be mildly interested to learn how that supposed extension works though.
It doesn’t. The very definition of Armstrong numbers excludes negative numbers.
See also A005188
In general, we pretty explicitly don’t spell out all the details about what inputs should and should not be expected. We’re pretty explicit that the unit tests are the source of truth and the documentation of those details.