Can anyone point out why I got WA for this solution of SAMESNAK? I am just not able to figure out where I went wrong in this: https://www.codechef.com/viewsolution/13772149

Some details of the solution:

swapper() ensures that a1 and b1 coordinates occur before a2 and b2 respectively.

in_range() checks whether the given value lies between 2 values (used for the case where they both belonged to a single row or column).

linear_checker() checks for the case when both of them lie in a single row or column(uses in_range).

row_column() checks for the case when one lies in a row and another in a column. Just checked the end points of the snakes here.