Snake collision

What will be the condition to check, if the snake collides with itself?

@Kashish08
In the update snake function, we add the new value of head of snake. Since collision is possible only due to head colliding with body, before new head is pushed in snake array you can check if the new head co-ordinates coincide with any previous body values.

Happy Coding !!

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Thank you, my doubt is cleared but the link you have provided to rate the experience isn’t working. It shows Page not found

@Kashish08
You can mail [email protected] for this
Happy coding !