Ad
  • Custom User Avatar

    Done. Thanks a lot. I sometimes struggle to understand properly the english details. The key part in these datails was this - "(if not already)". It only made a sense to my after reading your reply. Thank to you and thank to jimpjorps, who was probably trying to say the same thing. I just didn't catch what the words "passed integer" really meant. I thought it was something about the binar integer...

  • Custom User Avatar

    Thing is that 5 is already a single digit number, so you whould not even do bin(5). It's already the answer. Nothing needs to be done with 5.

    Codewars does not suggest that bin(5) should return 5. It suggests that single_digit(5) should return 5.

  • Custom User Avatar

    Copying my post here, since the full post with the code in it is hidden. See below...

    Thing is, that bin(5) is 0b101. That's two 1's. Not five! At least I think so. I wrote another code with different solution and both codes show the same. I also printed simple code, which returns the binar number. Not a reduced one. Just a normal binar number. Here are my two codes, including the print commands. What is wrong there? Why codewars suggests that the result for bin(5) should be 5 while the bin(5) == 0b101?

  • Custom User Avatar

    "If the passed integer is already a single digit there is no need to reduce." For single_digit(5), 5 is already reduced to a single digit. You don't need to do anything to it; just return 5.

    "2 should equal 5" means "your function gave me 2, but I expected 5".

  • Custom User Avatar

    I don't get it. I passed 108 tests and failed in 1. It says that the result of number 5 should return the value 2. How come?

    int(5) = 0b101 = 2. However, the log says: "2 should equal 5". Is there some other way how to get the value 5 when the input is 5 as well? Coding in Python.

    How did you solve it in the end? If you ever have... I'd say it must be an error.

  • Custom User Avatar

    Ahhh of course, always a good idea to read the description properly. Sorry!! :-/

    Thanks.

  • Custom User Avatar

    As Chrono79 mentioned:

    If the passed integer is already a single digit there is no need to reduce

  • Custom User Avatar

    The goal of this Kata is to reduce the passed integer to a single digit (if not already)

    No, if it is already a single digit number you have to return that number.

  • Custom User Avatar

    I think there is an error in the following:
    test.assert_equals(single_digit(5), 5)
    Shouldn't this test return 2 :-) ?