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.
Approved
Lua translation!
This comment is hidden because it contains spoiler information about the solution
Thanks for the response! I'll keep the spoilering in mind in the future. Sorry about that!
Well, what happens to
binary_sum
when the total sum equals to something like8+4+2+1
or1
? It only contains1
at the end of the array.When you're removing
0s
in your result (in the loop there), it got to the point where all 0s is already removed. Then, when it want to search a0
in the array, it cannot find one. That's why your code is throwing error.So, conclusion: You need to fix the if statement in the loop you used for removing leading zeros.
Next time, use Spoiler flag if you want to send your solution to the discourse. Not a kata issue.
This comment is hidden because it contains spoiler information about the solution
@hobovsky , that was 100% the problem. I missed it in the example code I even linked to. Thanks for pointing it out!
Did you
#include <bitset>
in your code?error: no member named 'bitset' in namespace 'std'
but it's supposed to be there... https://cplusplus.com/reference/bitset/bitset/
This comment is hidden because it contains spoiler information about the solution
What is your code?
why after I use the str()to print binary result, it still a number like 10? how can i change it like '10'?
This comment is hidden because it contains spoiler information about the solution
seems redundant ...
because it says "write to the binary string and return it":
given string
Loading more items...