small refactor
This commit is contained in:
parent
1c1c32a83d
commit
0405e3815c
19
main.go
19
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user