Skip to content

Commit e6894c3

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] fixed: Redefinition of the built-in function max.
1 parent 86a1d22 commit e6894c3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

exercises/projecteuler/problem0008.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const __BIT_SIZE__ = 32
1717

1818
func Problem0008(numberInput string) int {
1919

20-
var max = 0
20+
var greatest = 0
2121

2222
var digitsSlice []int32
2323
var bigNumSlice = strings.Split(numberInput, "")
@@ -41,12 +41,12 @@ func Problem0008(numberInput string) int {
4141
var currentProduct = helpers.Product(digitsSet)
4242
utils.Debug("Product beetwen %d and %d <%d> is: %d", i, i+interval, digitsSet, currentProduct)
4343

44-
if currentProduct > max {
45-
max = currentProduct
44+
if currentProduct > greatest {
45+
greatest = currentProduct
4646
}
4747
}
4848

49-
utils.Info("Problem0008 => The the greatest product of %d consecutive digits is: %d", interval, max)
49+
utils.Info("Problem0008 => The the greatest product of %d consecutive digits is: %d", interval, greatest)
5050

51-
return max
51+
return greatest
5252
}

exercises/projecteuler/problem0011.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func Problem0011(matrix [][]int, interval int) (int, bool) {
1414
return 0, true
1515
}
1616

17-
var max = 0
17+
var greatest int = 0
1818

1919
var quadrantSize = interval
2020
var matrixLimit = len(matrix) - (interval - 1)
@@ -33,8 +33,8 @@ func Problem0011(matrix [][]int, interval int) (int, bool) {
3333
diag1Acum *= matrix[i+k][j+k]
3434
diag2Acum *= matrix[i+k][j+(quadrantSize-1)-k]
3535

36-
max = helpers.IntMax(diag1Acum, max)
37-
max = helpers.IntMax(diag2Acum, max)
36+
greatest = helpers.IntMax(diag1Acum, greatest)
37+
greatest = helpers.IntMax(diag2Acum, greatest)
3838

3939
// reset lines
4040
var verticalAcum = 1
@@ -46,14 +46,14 @@ func Problem0011(matrix [][]int, interval int) (int, bool) {
4646
verticalAcum *= matrix[i+k][j+l]
4747
horizontalAcum *= matrix[i+l][j+k]
4848

49-
max = helpers.IntMax(verticalAcum, max)
50-
max = helpers.IntMax(horizontalAcum, max)
49+
greatest = helpers.IntMax(verticalAcum, greatest)
50+
greatest = helpers.IntMax(horizontalAcum, greatest)
5151
}
5252
}
5353
}
5454
}
5555

56-
utils.Info("Problem0011 max => %d", max)
56+
utils.Info("Problem0011 greatest => %d", greatest)
5757

58-
return max, false
58+
return greatest, false
5959
}

0 commit comments

Comments
 (0)