Aggresive cows problem

in these vedio sir is making for 3 cows but when there is only two cows what will happen then the code may be goes to wrong

He has considered only one case here. You can generalize the approach.
You can refer this video