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.
thats neat!thanks
@nabramow
you could test it yourself in the console.All it does is convert it to a number, convert to Boolean, then finally convert it back to a number
(operand -> number -> Boolean -> number).
Unary Plus or "+" converts an operand to a number, provided it is in an integer format. E.G.
+"5"
=>5
. The first use of it converts a string integer to an integer. Then second use of it converts the Boolean (true or false) to its integer equivalent; false = 0, true = 1.Logical NOT operator or "!" will return true if the operand is empty or non-functional, and return false if it's not empty or it's functional. In terms of integers, this means it will return false if the integer is not equal to 0. It does this by negating the operand. E.G.
!5
=> false.let's have this in steps:
str2
is a string but contains a number.+str2
converts that strign to a number.!+str2
converts that number to a boolean and inverts. This way it becomes either false if non-zero or true if zero.+!+str2
converts that boolean back to a number, now we have either 0 or 1.So this +!+str2 is just a way to put "give me 0 if str2 is not
"0"
, otherwise give me 1".Would someone mind explaining what the +!+ does? I'm not quite sure what to google for more info.
Are you from China?
Test cases have changed. There was a semi brute force approach that did work for numbers 1-20. Numbers have increased to 200.
This comment is hidden because it contains spoiler information about the solution
I past all the test, but still have this error "Process was terminated. It took longer than 6000ms to complete" why??
I have the same problerm!
+!+str2 is so cool, and i write this in a long string.
I like this solution
This comment is hidden because it contains spoiler information about the solution
66666666