I learned that off-by one errors, mixing up arguments and caches are hard to debug.
I have easily spent days debugging many such problems which were almost always solved by a one line change. And rarely did I find ways to prevent similar bugs in the future bugs by improving testing or code factoring.