Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
neat, but not a best practice at all, which thankfully the votes have reflected haha
Why?
bad practice
very neat
its not nesesarelly as mission of any function is provide back a result of task it was created to do.
This comment is hidden because it contains spoiler information about the solution
This is one of the most elegant solutions, though might not be the most performat one. Consider tail call optimization for this.
Frankly speaking, I doubt that your code is called with wrong arguments.
trace
is unreliable here, because of shrinking: after finding[27,15,15]
QuickCheck tries to find a smaller counter-example, invoking tests with[27,15,14]
and, I suppose, some other combinations. That is why you see[27,15,14]
in trace output.Looking at this actually seems to reveal the issue, as logging the input arguments (with
trace
+show
) shows that my code is called with[27, 15, 14]
(which ends in 7) instead of[27, 15, 15]
(which ends in 3).Could you please show full test log? I cannot reproduce the issue. Definitely,
lastDigit [7,11,2]
should be7
.The following Haskell test case fails for me: lastDigit [7,11,2], expected 3 but got 7. However, checking 7^(11^2) in Wolfram Alpha shows that the last digit is, indeed, 7.