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.
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...
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 thatsingle_digit(5)
should return 5.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?
"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".
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.
Ahhh of course, always a good idea to read the description properly. Sorry!! :-/
Thanks.
As Chrono79 mentioned:
If the passed integer is already a single digit there is no need to reduce
No, if it is already a single digit number you have to return that number.
I think there is an error in the following:
test.assert_equals(single_digit(5), 5)
Shouldn't this test return 2 :-) ?