diff options
| author | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-23 16:39:45 -0400 |
|---|---|---|
| committer | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-23 16:39:45 -0400 |
| commit | 340c72e61917d1029ca45f6c5ca91f4c4c4b987d (patch) | |
| tree | d238efeb2b23ddb991ce4279a51079bec149c36e | |
| parent | 2b256bab45712e5f0ba883bb40a99ab29682defc (diff) | |
feat: print a prettified report of the winner
| -rw-r--r-- | main.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 { |
