summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-23 16:39:45 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-23 16:39:45 -0400
commit340c72e61917d1029ca45f6c5ca91f4c4c4b987d (patch)
treed238efeb2b23ddb991ce4279a51079bec149c36e /main.go
parent2b256bab45712e5f0ba883bb40a99ab29682defc (diff)
feat: print a prettified report of the winner
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.go b/main.go
index beae39f..5d0829e 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"log"
+ "math"
"math/rand"
"sync"
"time"
@@ -73,9 +74,16 @@ func game(numPlayers, faces int) {
close(scores)
}()
+ minScore := Score{score: math.MaxInt}
+
for score := range scores {
- fmt.Printf("%v\n", score)
+ if score.score < minScore.score {
+ minScore = score
+ }
}
+
+ fmt.Printf("Player %d won with a score of %d\n", minScore.id, minScore.score)
+ fmt.Println("Thanks for playing!")
}
func throwDie(faces int) int {