Python Resistor Color Trio currently doesn’t test for values over 1,000 which cannot be represented as kiloohms.
There is one test with zeros = red (2) … which is for value 2,000. This allows code the following to pass, which would generate incorrect values for zeros = red (2) and the second digit as anything other than 0. Note: this solution is akin to something that was used in a solution I was mentoring and not speculative.
if value > 1000:
return f"{num // 1000} kiloohms"
return f"{number} ohms"
Upon looking at the canonical data for this exercise, I see the canonical data doesn’t address that case, so this is more of a question for the canonical data than Python.
Should I open an issue on that repo or keep discussions here?
The awk version of this test has much more comprehensive testing (and extends the units). Thoughts on syncing from awk test cases to the canonical data?
We use the canonical data for the exercise.
If you are up for updating that canonical data you are free to do so(by me) and the python track will probably bring in those changes.
We don’t do that many costum cases and try to relay on canonical data to cover most cases. There are cases we make our own tests, like error hanedling and if there is a specific case we want to cover.
Although for this exercise we wont do an extra test to cover that case unless it comes directly from canonical data.
I just bumped into this myself on the Elixir track. I was about to open a new topic, but this one was detected as similar. Nice .
The linked PR has some interesting discussion, namely that the case red, red, red is ambiguous: it could be 2.2 kiloohms or 2000 ohms. Different tracks seem to have different example solutions. It would lead to churn for many tracks if one solution was picked over the other.
While I completely understand that, I still find the current situation a bit dissatisfying. I have looked at community solutions of Elixir to learn from them, and I’ve found that some of the top-listed ones are actually “incorrect”, meaning their solution loses precision in some cases. (red, red, red -> 2 kiloohms) Now I’m not sure what I want to do for my own solution.
I’m not really advocating for some specific action, just wanted to share my experience.
Per the discussion in the above PR, there’s different opinions about what is “correct” in this situation. It’s hard to objectively label something as incorrect when some people think that’s the most correct solution