Here’s the link and picture of my code:
** Ignore the code below “#my original code” - I was just using it for myself to compare between the versions
So… what does the -1 mean in line 4 again?
And is there any other ways to solve this question?
It would appear to be accounting for something that is inherent that skews the result.
The intermediate operation splits on
x; the return polls the length of that list. So far, so good. Now is when our imagination needs to kick in.
Note, we need to be skeptical, and not accept that the
- 1 is proven. Don’t look for an answer that supports what you think (confirmation bias). Look for the solution that is supported by good evidence.
Why not put in some print() statements to see what the variable splits actually is (and to get a better idea of what the split() method does)?
Try it with various inputs.
Gotcha. So after the split it will leave a blocks of chars on each side and the answer is the total numbers of blocks -1… duh