Retired
Add 3 bits (retired)
66 of 155GeorgeGkas
Loading description...
Binary
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
At first I thought this is about adding binary digits, it is the literal sum of 3 values
better to return empty list in case of incorrect input, avoiding multiple output types
So, what are we supposed to do?
At first I didn't understand either. You need to sum all the arguments (they are in decimal) and convert the result to a binary as an array.
Thanks!
There are hundreds of katas where half of the work is distinguish True/False from 0/1.
Why fight against language (in python
True == 1
) in every little kata?This comment has been hidden.
Fixed.
This killed almost all of the solutions.
Please review the description. You mention that 1 is equivalent to 00, 2 to 01, 3 to 10, and 4 to 11 in binary, when these are obviously false.
Other than that, great kata!
Actually there is no issue: "
0, 1, 2, 3
are represented in binary format as00, 01, 10, 11
", which means 0 <=> 00,, 1 <=> 01, 2 <=> 10 and 3 <=> 11, which is the desired behavior. Please confirm it to resolve the issue.Resolved.
Maybe add a mention that the output array must be at least two elements long. I had to discover this by accident.
I will thanks! But this can be understood from the examples as well.
Minor issue: the first Python example test's expected answer and the error text do not agree on the correct amswer.
Thanks for the report! I have fixed it.
The kata is now better with input validation and 15 fixed assertions in total isn't bad but it still can be further improved by the addition of 100+ random test cases; otherwise, hardcoded (cheat) solutions like this one could pass easily without actually implementing the algorithm required.
I added 100 random tests. Thank you very much for your help! Do I have to consider anything else?
This comment has been hidden.
Since each of the three arguments passed into
add3bits
can only ever take2
possible (valid) values, perhaps you could make the Kata a bit more interesting by introducing input validation? For example, you could extend the current spec such that the following should throw anError
:This will be nice feature indeed. I'll update soon. Thanks!
Updated!
Thanks for responding to my Suggestion but ideally you should explain clearly in the Description when exactly
null
/None
should be returned. One should not need to look at the code examples to guess when to returnnull
/None
, cheers :)And how to distinguish between languages? Should I add a note? Somenthing like "For python coders return
None
for JS returnnull
"?Yep, that's good :)
EDIT: You still haven't explained when
null
/None
should be returned though. I would suggest editing the "Output" section of your description to the following:1 == 0b00
?!?"Decimal physical numbers" ? And you have uninvented
0
(as a "decimal physical number") ?The description is a bit (no pun intended. no, really) weird and does not fully match with the task,
x
,y
andz
being "numbers that represent bit values", so not bits but numbers, probably decimal physical ones, so1
should be encoded as00
(well,[0]
) and0
is unspecified.I'd just call decimal numbers "decimal numbers", and make the representation of bits consistent throughout the whole kata.
If I understand correctly, do you suggest to change the phrase "decimal physical numbers" to "decimal numbers" and represent all the outputs as arrays of length 2?
Updated!
I have seen your updated description. In this description, it still seems that you mean to correspond 1 <--> 00, 2 <--> 01, 3 <--> 10, 4 <--> 11. Then how am I supposed to add 0, 0, and 0? If the bits are parts in your 2-bit code, the summation is pointless (because the 2-bit code is not defined in a usual way, and you must also define the rules of addition again).
I guess that there are at least two possible interpretations:
The corresponding rules are mis-written. They should be 0 <--> 00, 1 <--> 01, 2 <--> 10, 3 <--> 11. That is how the common binary numbers are defined. If you mean this, could you please consider to change '1, 2, 3, 4' to '0, 1, 2, 3' in your kata description?
Otherwise, probably the bits are added in the common way. Since the sum lies in 1..3, the sum is encoded in your current version of corresponding rules. However, in your test case, the sum 0 <--> expected result [0, 0]; this interpretation is not OK in the current state.
Yeap you are right, I've missed this part. I updated my descripition.