I started coding and tested the game by using the same code for both the snakes(during the event, one snake will use your code and the other will use your opponent's code). After a couple of days, I thought I've done whatever I could do and submitted the code. As I'm not a great programmer, I didnt plan the algorithm at the beginning. I kept changing the structure as I kept testing the game. during submission, I could easily see that my code was divided into 4 parts.
1) Locating all the 4 food particles
2) Locating the food particle that is nearest to the snake's position
3) An initial instruction for navigation towards the food(avoiding the boundary)
4) Checking whether the initial instruction is a valid move(bumping into yourself or the opponent means you are out of the game!) and giving a valid and safe instruction.
This code works efficiently until the randomly generated food makes you move in such a way that you make a trap for yourself!
In the above picture you can see the snakes moving towards the nearest food.
In this picture, snake a bumped onto itself and lost the game!
As, many of the participants(except one) coded in a similar way, it was obvious that the random generation of the food will be the factor determining the winner. The better your luck, the greater your chances of winning. My luck was so good that my code won the second position!! Only later I heard from the organisers that the guy's code which won the first place was far more superior than the rest. That code was such that the snake wont trap itself often and also it'll try to blog the opponent and trap it!! How about that?!?!