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.
I do not know. Try clearing the cache or something. I tried your code with example test samples in Py3.60 and it passed all of them, including the
-10/7
.Okay, I see the problem. I wrote this kata long ago when only Python2 was supported, therefore it was available in Python2 only. You wrote your code for Python3 and tried using it in Python2, but difference between versions of the language made it produce wrong result.
Now I created a version for Python 3.60. Try choosing Python 3.60 in trainer instead of Python 2.7 and see if your code works there.
Or you may still try to adapt your code for Python 2 and gain some experience in understanding how it is different from Python 3.
Dear Rhuergo! Are you sure you've chosen the correct version of Python? I've tested your code in repl.it. Your code does not give correct results in Python 2, but produces correct output for "-10/7" in Python 3 there. Make sure you choose the correct implementation here, as several versions of Python are available and they may have differences - e. g. in Python 3 single slash is float division by default, but in Python 2 it defaults to integer division.
Once again, you can see how your code behaves here by inserting
print(p_entera, numerador, denominador)
before your last if-(if-else)-else block.Rhuergo, looks like Python interger division with negative numbers works not the way you expect, hence the problem. It floors the result, therefore in Py2
-10/7
evaluates to-2
. Meanwhile, you expect it to ceil the result if the result is negative. This is what causes problems in your solution. You have to find a workaround.Another tip: you can always use
print
to show yourself the value of variable(s) at certain stage. Use it to debug your solution. It helps a lot.spoiler flags! x/
Please show your code. The statement
'-2 4/7' should equal '-1 3/7'
means that your code actually returns-2 4/7
.12876 / 17030 != 31 / 41
...Do you expect people to know what you're talking about when you don't provide the input for this test?
For the record, the input is
[[6, 13], [187, 1310], [31, 41]]
. You can calculate by hand that the lcm is 698230.Please reflect on yourself before saying the test is wrong, and if you want to say the tests are wrong you need to give enough info to let others know (and follow up) what you're talking about. It's the no.1 mistake newbies make on this site ;-)