8 kyu

Fix the Bugs (Syntax) - My First Kata

3,636 of 10,773donaldsebleung
Description
Loading description...
Debugging
  • Please sign in or sign up to leave a comment.
  • MilanGrujicic Avatar

    Why I get ZeroDivisionError: integer modulo by zero. How to address if a or b is zero? The instructions only say 'If a and b are both numbers, neither of a or b will be 0.'

  • OlofL Avatar

    You may assume the following: If a and b are both numbers, neither of a or b will be 0.

    But the random tests give me ZeroDivisionError: integer modulo by zero

    in Python3

  • Gooz92 Avatar

    Not ideal description but thank you anyway! Keep trying to do something that inspires you :-)

  • workoneluv Avatar

    Nice Kata, bro

  • LetMeDie Avatar

    "Hello, this is my first Kata so forgive me if it is of poor quality" -> Don't be afraid, you are forgiven!

  • AmirTallap Avatar

    I've passed the kata, didn't change anything, passed my second submission. There is something wrong with the auto generated test cases

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • brandenge Avatar

    The problem states that if the arguments are numbers then it can be assumed that neither will be 0. But I am getting a division by zero error in the random tests.

    Traceback (most recent call last):
      File "/workspace/default/tests.py", line 22, in <module>
        test.assert_equals(my_first_kata(a,b),sol(a,b))
                           ^^^^^^^^^^^^^^^^^^
      File "/workspace/default/solution.py", line 5, in my_first_kata
        return a % b + b % a
               ~~^~~
    ZeroDivisionError: integer modulo by zero
    
  • konung-nvkz Avatar

    Funny in JS. Thank you!

  • televisionia Avatar

    This comment has been hidden.

  • EmsleyD Avatar

    ChatGPT confirms my function (in JS) is correct but it won't pass the tests. Any pointers? Not sure where I am going wrong (not sure that I am to be honest!)

  • RP_Dev Avatar

    In my case I had zero division and a test with a boolean that was passing as integer failing...

  • FuzzyPyjamas Avatar

    The kata should also have test for float values considering that real values(float) are also numbers

  • farhanaditya Avatar

    Your katas have improved a lot since then :)

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • rafaelhasan Avatar

    First it was giving me 1 error. I hit attempt again with the same code. It was 2 error. I tried again. And finally it was passed all with the same code. :D

  • cekstedt Avatar

    Small quibble: Duck typing is best practice in Python, and also in Python3 booleans are a subclass of integers, meaning that arithmetic will work between bools and ints. However, when a boolean is passed in the random tests, a "False" is expected, which would force a programmer to use type-checking. Since this is an 8 kyu kata, and likely to be teaching new programmers, I would suggest either changing the expected value of those tests to reflect booleans as a number, or just removing booleans from the Python random tests entirely (if you think that this issue is over the level of an 8 kyu).

  • Chrono79 Avatar

    This comment has been hidden.

  • ThatOneGuy2029 Avatar

    Great job on a first kata. These debugging Kata are great as debugging is a skill required for any coder.

  • TheLamia Avatar

    Gosh... this Kata should not be giving me these feelings of rage xD

    Good job at reminding people why debugging code of people new to a language is so irritating to find yourself having to do xD

  • michal1 Avatar

    According to kata description:

    You may assume the following:

    If a and b are both numbers, neither of a or b will be 0.

    but unfortunately, when I check my solution, appeared this error:

    return (a % b) + (b % a) ZeroDivisionError: integer division or modulo by zero

    I did this kata in python.

  • mkrahulec Avatar

    It appears that now that we have Ruby 2.5.0 available in Codewars that some of the tests are causing a warning as they are using Fixnum which has been deprecated... This is causing answers to fail that should be valid (they still work in 2.3.0)

  • bestwebua Avatar

    It's too hard kata, indeed :) Thanks!

  • jgdodson Avatar

    For the dynamically-typed languages, the tests should cover all possible numeric types since the description specifies only that arguments must be numbers. That, or the description should say integers.

  • Vorgue Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    CoffeeScript Translation Kumited! Please Accept :D

  • seamusMcManus Avatar

    I enjoyed this kata quite a bit. Well done!

  • ReLoa_D Avatar

    The output frame lights with green, but it writes that I have 1 Error, but I haven't nothing in console

  • sioniks Avatar

    Good kata for beginner

  • jjustian Avatar

    I ended up using typeof but i really wanted to use parseInt... didnt know about isNaN().

  • lepatissiere Avatar

    The instruction false/False`` plusb % a``` if both arguments are numbers confused me as I wasn't sure if I was just supposed to print the output as " " + b + "%" + " " + a . The output result seemed to have shown numbers instead of an evaluated result. All in all, a really good practice for beginner like me. Need more practices like this.

  • alessandro.giordo Avatar

    This comment has been hidden.

  • bugman4 Avatar

    This comment has been hidden.

  • aboutandre Avatar

    Love this Kata. I just started learning JS a few months ago. It's hard to find good excercises for beginners.

    Keep them coming! ;-)

  • acraileanu Avatar

    As a general rule, it's not a good practice for a function to return different data types based on the input. I suggest throwing an error when the arguments are invalid.

  • ecolban Avatar

    The description should specify the return value when one of the arguments is zero. I would think that it should return False in this case. The test cases should test for division by zero.

  • rbeer Avatar

    The Python version of this kata doesn't provide any code. That makes the instruction "In this Kata you should try to fix all the syntax errors found in the code." very confusing.

  • GiacomoSorbi Avatar

    Nice beginner kata; translated into both Ruby and Python if you want to approve them (and let me know if you cannot see two translations).

    You might then want to use Test.describe and Test.it instead of mere console.logs to add messages and group your code. Let me know if I might be of some help :)

  • Steadyx Avatar

    Greate kata man! :)

  • WinterCore Avatar

    Great kata in general and good to hear that you started writing your own katas. keep it up :D

  • matt c Avatar

    Could do with some random test cases to prevent hardcoded solutions :)

    Also assertEquals should have the actual then expected values passed in

  • Jotha Avatar

    Great, that you started at writing your own katas!

    To increase your kata's quality you should provide some example test cases. Especially in your kata it's not absolutly necessary, but in general, it will help codewarriors to understand what the got to do.