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.
seems to me like the dart version codewars has installed is 32bit and thus has ints of size 32 where your numbers don't fit. that's not a kata issue.
new RegExp(s)
is the syntax used to create a new regular expression (often abbreviated with regex) in dart.In order to do so, it internally parses the String s, verifying that it is a valid regex in the process.
Now we must know that parentheses are part of the syntax for regexes (specifically, they are used to define so called capture groups) and they need to be nested exaclty like this kata is asking in order to be a valid in it.
In this code, the author is testing if
new Regexp(parentheses)
executes correctly (if so, the input is valid) or throws an exception (input is invalid).The fact that this works is a coincidence and this may not be great for production code. Nonetheless it is a concise solution that just works and certainly a great way to remind us the power of the too often neglected regular expressions 😆
I cannot say what is actualy wrong in the code but i know which test fails:
console.log("Result from my solution is "+iqTest("1 1 2")); --> should be 3 but is 2
console.log("Result from my solution is "+iqTest("1 2 2")); --> should be 1 and is 1
console.log("Result from my solution is "+iqTest("1 2 1")); --> should be 2 but is 1
I think your code just checks for a change but does not take into account the next step
Not a kata suggestion, don't post solutions in Discourse.