Skip to content

Commit

Permalink
day 240: add implementation comment about symmetry
Browse files Browse the repository at this point in the history
  • Loading branch information
vaskoz committed Apr 20, 2019
1 parent aba46af commit e07ca0f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions day240/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func minSwapsAdjacentPairs(pairs []int, indicies map[int][]int, pos int) int {
return minSwapsAdjacentPairs(pairs, indicies, pos+2)
}
min := int(^uint(0) >> 1)
// NOTE: It doesn't matter which one you swap due to symmetry.
swapWithSecond := indicies[first][1]
pairs[secondIndex], pairs[swapWithSecond] = pairs[swapWithSecond], pairs[secondIndex]
if minBelow := 1 + minSwapsAdjacentPairs(pairs, indicies, pos+2); min > minBelow {
Expand Down

0 comments on commit e07ca0f

Please sign in to comment.