Harsh Shastri

Reputation Score: 144

Submit An Answer

Answers ( 1 )

 
  1. Nicholas G 310 Accepted Answer Community Answer

    These types of errors make your blood boil sometimes, lol. You always end up looking for the bug and then when you find it, it's something so small and stupid. As for me, I always forget if slice or splice is inclusive to the index the slice goes up to. I think that's where many cases of off-by-one comes in. It has something to do with not realizing whether or not you're being inclusive to the current or ending indexes. What's really tricky is when you get off by one errors in tree manipulation at multiple levels...or even worse, an inconsistent off-by-one error where you are off-by-one only on some levels of the tree but not others in the same branch. On a side project that I am involved in with a friend, we are splicing rose trees at multiple levels like a zipper from the leaves up but stopping at the lowest point in which all of the selected nodes under it are included under a new branch node that we place in the tree at a given level. Think manually manipulating a virtual DOM tree by adding and removing selections across subtrees. We dealt with off-by-one errors very often and it was mostly due to edge cases. We eventually figured it out but damn, that was brutal. 

    UTC 2020-10-13 12:31 AM 0 Comments

To answer this question, you must be logged in.

Create an account

Already have an account? Login.

By Signing up, you indicate that you have read and agree to Sage's Terms and Conditions and Privacy Policy