Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Default User Avatar
  • Custom User Avatar

    Please show your code. The statement '-2 4/7' should equal '-1 3/7' means that your code actually returns -2 4/7.

  • Default User Avatar

    12876 / 17030 != 31 / 41

  • Custom User Avatar

    ...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 ;-)