switched rounding function
This commit is contained in:
parent
1449da6551
commit
5d5300a48e
@ -30,8 +30,8 @@ struct Day07: Runnable {
|
||||
|
||||
func runB(horizontalPositions: [Int]) {
|
||||
let average = Double(horizontalPositions.reduce(0, +)) / Double(horizontalPositions.count)
|
||||
let roundedDown = Int(floor(average))
|
||||
let roundedUp = Int(ceil(average))
|
||||
let roundedDown = Int(average.rounded(.up))
|
||||
let roundedUp = Int(average.rounded(.down))
|
||||
let fuelForRoundedDown = fuelConsumptionFor(horizontalPositions: horizontalPositions, toPosition: roundedDown)
|
||||
let fuelForRoundedUp = fuelConsumptionFor(horizontalPositions: horizontalPositions, toPosition: roundedUp)
|
||||
print(min(fuelForRoundedDown, fuelForRoundedUp))
|
||||
|
Loading…
Reference in New Issue
Block a user