Skip to content

Commit

Permalink
Refactor transposition function for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
meyermarcel committed Jul 19, 2024
1 parent d4a548f commit 02a8797
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cont/transposition.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func CheckTransposition(ownerCode string, equipCatID rune, serialNum int, checkD

// 5, 4, 3, 2, 1
for idxRight := 5; idxRight > 0; idxRight-- {
// 0, 1, 2, 3, 4
idxLeft := (idxRight * (-1)) + 5
swapped, transposedSerialNum := swapDigits(serialNum, idxRight-1, idxRight)
if !swapped {
continue
}
calcCheckDigit := CalcCheckDigit(ownerCode, equipCatID, transposedSerialNum) % 10
if checkDigit == calcCheckDigit {
contNums = append(contNums, TpNumber{Number{ownerCode, equipCatID, transposedSerialNum, calcCheckDigit}, idxLeft})
// 0, 1, 2, 3, 4
pos := idxRight*-1 + 5
contNums = append(contNums, TpNumber{Number{ownerCode, equipCatID, transposedSerialNum, calcCheckDigit}, pos})
}
}

Expand Down

0 comments on commit 02a8797

Please # to comment.