For row 1 to r
For col 1 to c
// Collision with U, we check on diagonal path only
if S[r_init][c_init]==‘U’ and S[row][col_init]!=’#’
//Check for straight line paths if there isn’t any ‘#’ on the path
And score ++;
It will be more or less copy paste of this part for different kind of meets .
if you want some help please ask in comments…!