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.
System.out.println
should work in java tests, and, as a matter of fact, it worked when I tried it. Are you sure you get nothing printed? Are you sure you are not trying to print an empty string or something like that?I'm trying to practice Java at the moment and am a native python user. I was wondering what's the reason why you can't simply type System.out.println() to debug a problem? Whenever I use System.out.println(x), it amounts to nothing on the console.
Test.assert_equals
takes two arguments: the value your function returns and the expected value, your function only takes a single argument, see the function definition.From the kata description:
In
[2, 3, 4]
the missing number is 1 and your code doesn't work for that.BTW, when you make a single line code block, there is no need for the python label, use it only when doing a multiline one (single backtick vs triple backticks)
@Chrono79 Understood. Sorry about that. I believe I am confused about the code written in sample test. It says
python Test.assert_equals(find_missing_number([2, 3, 4]), 1)
.Does this mean that the function should have two parameters? first for the actual list and the second for that missing number? Or am I overthinking?
Try keeping the same problem in the same thread, opening more than one is a little messy. Apart of timing out, your code is failing two sample tests, so, first I would try making my code pass the sample test and then I'll try making it faster, because the final tests are really long, note there is a PERFORMANCE tag in this kata. Try using some math.
Repost
Here is the updated code. But it gives the timeout error when i try to attempt the kata.
This comment is hidden because it contains spoiler information about the solution
Sorry about this. I didnt realize that it was showing an error. I shall repost with the updated code.
I typed
python *mycode*
in the previous comment. Which is exactly earlier. Please let me know if the problem still persists.C Translation is ready (author is inactive).
Also, the random tests in C# seem really bizzarre, and I don't think they're doing what the author intends. They appear to be running 7000 tests over the same set of 2000 arrays, and none of the test sizes come close to the JavaScript performance tests. I'm hesitant to change them, though, as many existing solutions could start failing due to signed integer overflow.
ah yes, my mistake. the OP had a previous post where the code would sometimes pass. then that code was edited several times, so I've lost track
It's not the indentation, it's the lack of initialization.
Hi @opeth22, your code indentation causes this:
UnboundLocalError: local variable 'answer' referenced before assignment
, so repost your code with the correct indentationThis code gives the answer of the missing number but also gives the timeout error. Need help!
I did it with callback function but it solution had problem with memory. I broke my mind. I have red a tip that I have to think about math solutions. Done.
Loading more items...