Simplify the function

Add abs function to get only positive results of a's and b's indexes substractions. Remove the list with positive and negative values of the indexes substraction and simply replace it with number 4 in th if statement.