From 0405e3815c0fbcf4162b8f25aa978fa6c6d8a982 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 14 Apr 2024 15:12:49 -0400 Subject: [PATCH] small refactor --- main.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 35961e8..0facdb4 100644 --- a/main.go +++ b/main.go @@ -380,16 +380,7 @@ func simulateElection(states []State) int { election_sample := sampleFromState(state) republican_seats += election_sample.Republicans } - - if dev { - fmt.Printf("\n\n(%d) ", republican_seats) - } - if republican_seats >= 270 { - return 1 - } else { - return 0 - } - + return republican_seats } func main() { @@ -405,13 +396,11 @@ func main() { p_republicans := 0.0 for i := 0; i < n_sims; i++ { - result := simulateElection(states) - if dev { - fmt.Printf("Election result: %d", result) - } - if result == 1 { + republican_seats := simulateElection(states) + if republican_seats >= 270 { p_republicans++ } + fmt.Printf("%d - %t\n", republican_seats, republican_seats >= 270) } p_republicans = p_republicans / float64(n_sims) fmt.Printf("\n\n\n%% republicans: %f\n", p_republicans)