Again, this solution is the most starred solution in the Elixir track with more than twice of stars as the second one.
def isbn?(isbn), do: isbn?(isbn, 10, 0)
def isbn?(<<c, rest::binary>>, n, sum) when c in ?0 .. ?9, do: isbn?(rest, n - 1, sum + n * (c - ?0))
def isbn?(<<c, rest::binary>>, n, sum) when c == ?-, do: isbn?(rest, n, sum)
def isbn?("X", _, sum), do: isbn?(<<>>, 0, sum + 10)
def isbn?(<<>>, 0, sum), do: rem(sum, 11) == 0
def isbn?(_, _, _), do: false
This solution will pass all tests but will accept “81X”
as a valid ISBN. Yet this solution
def isbn?(isbn), do: isbn?(isbn, 10, 0)
def isbn?(<<c, rest::binary>>, n, sum) when c in ?0 .. ?9, do: isbn?(rest, n - 1, sum + n * (c - ?0))
def isbn?(<<c, rest::binary>>, n, sum) when c == ?-, do: isbn?(rest, n, sum)
def isbn?("X", 1, sum), do: isbn?(<<>>, 0, sum + 10)
def isbn?(<<>>, 0, sum), do: rem(sum, 11) == 0
def isbn?(_, _, _), do: false
Will work correctly. Try spotting the difference. It’s obvious there is a bug in the first one. It’s obvious that the test suite is insufficient which caused this bug to go unnoticed for two years. I’m professionally in the IT industry for 25 years and was coding for more than ten years prior. I must admit the first time I came across rules which prevent extending the test suite in cases like this. I’m baffled. Sorry. I’m perplexed.
Who makes those rules? When I recount all hoops I had to go thru to even get here just trying to help and fix the issue. All those welcoming messages and videos and then your PR can’t even keep open for seconds. Do you want help? If not, I can just go. I have never come across a community that was that vehemently rejecting any attempt to help.