Leave a rating/review
How’s your golf range? Everyone wants to get par, but more often than not you’re under, or even worse, over par. In this challenge, you’ll summarize a golf player’s range at a given point in the match, which is dictated by the number of current scores.
At the end, the console should print out something like: “You have golfed $COUNT holes, with a min of $MIN and a max of $MAX, with an average course par of 4.”
$COUNT, $MIN and $MAX should be determined from the array of values representing the scores. The starter project already contains a sample array of scores. Pause the video, try out your solution, and come back when you’re ready to see my solution. Good luck.
The solution for this challenge involves three sequencing operators. Since those operators are greedy, however, you need to run each one separately.
var min: Int = 0
var max: Int = 0
var count: Int = 0
scores
.print("publisher")
.min()
.sink {
min = $0
}
scores
.print("publisher")
.max()
.sink {
max = $0
}
scores
.print("publisher")
.count()
.sink {
count = $0
}
print("You have golfed \(count) holes, with a min of \(min) and a max of \(max), with an average course par of 4.")