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.
Sure! Thanks a lot!
It works without return because the sample test (scroll a bit to see it in the coding page) tries to call factorial(). Talking about what he imported from math, factorial, it is imported as a function after all. Hope you get it.
This comment is hidden because it contains spoiler information about the solution
And... Why it works without a return (nor even rest of the code)? :/
Why did I not think of this...
It's a horrible idea to use try/except for completely preventable exceptions.
Use spoiler flag if your comment contains info about solution.
Cybersamurai, wdym? It works perfectly, I just tried it.
Please mark your post as having spoiler content next time. Your post was visible in the homepage discourse.
This comment is hidden because it contains spoiler information about the solution
The problem states that the array has every integer from 1 to n exactly once except for some integer in between, which appears twice. The array that you're testing on doesn't fit this description (it has a 9 but no 6, for example), so the solution doesn't work.
I tried this with: arr = [1, 5, 7, 3, 2, 9, 2, 8]
And it returned 9 instead of 2 :/
can I strike my answer from ever having existed? is what I thought when I saw this
so clever
It's not faster, if you run the code, you'll notice that the time varies a lot between one and the other, sometimes one is faster and sometimes the other, and endswith is written in C for performance.
Loading more items...