Created
December 3, 2023 09:32
-
-
Save rosenbergm/60e09417cc5ef63809a1988a67f35965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod solution; | |
use solution::Simulation; | |
fn main() { | |
let mut simulation = Simulation::new(); | |
let prg = simulation.new_city("Prague"); | |
let brn = simulation.new_city("Brno"); | |
let pls = simulation.new_city("Plzen"); | |
let hrk = simulation.new_city("Hradec Kralove"); | |
let unl = simulation.new_city("Usti nad Labem"); | |
// Praha - Plzen | |
let d5 = simulation.new_road(&prg, &pls, 70); | |
// Praha - Plzen | |
let d11 = simulation.new_road(&prg, &hrk, 70); | |
// Praha - Brno | |
let d1 = simulation.new_road(&prg, &brn, 120); | |
// Praha - U. n. L. | |
let d8 = simulation.new_road(&prg, &unl, 100); | |
simulation.new_bus(&[&pls, &prg]); | |
simulation.add_people(&pls, &prg, 120); | |
simulation.new_bus(&[&brn, &prg]); | |
simulation.add_people(&brn, &prg, 60); | |
simulation.new_bus(&[&hrk, &prg, &brn]); | |
simulation.add_people(&hrk, &brn, 40); | |
simulation.add_people(&prg, &brn, 40); | |
for event in simulation.execute(130) { | |
let name = event.city().name(); | |
let people_got_off = event.got_off(); | |
let people_got_on = event.got_on(); | |
println!( | |
"E{}: {}: {} got off, {} got on", | |
event.epoch(), | |
name, | |
people_got_off, | |
people_got_on | |
) | |
} | |
println!("---"); | |
simulation.new_bus(&[&prg, &brn]); | |
simulation.new_bus(&[&pls, &prg, &brn]); | |
simulation.add_people(&prg, &brn, 40); | |
simulation.add_people(&pls, &brn, 10); | |
for event in simulation.execute(800) { | |
let name = event.city().name(); | |
let people_got_off = event.got_off(); | |
let people_got_on = event.got_on(); | |
println!( | |
"E{}: {}: {} got off, {} got on", | |
event.epoch(), | |
name, | |
people_got_off, | |
people_got_on | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment