summaryrefslogtreecommitdiff
path: root/2020-overdrive/src/main.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2022-04-19 21:37:58 +0200
committerJustin Wernick <justin@worthe-it.co.za>2022-04-19 21:37:58 +0200
commitf38ef5a22222e368bf2bfa1c1c652d48e5493369 (patch)
tree4b5bd2401a696e45031b18198157c7c00d566c16 /2020-overdrive/src/main.rs
parent4e2436703a90c2ca45dcb0d2584968a0340220d7 (diff)
parentf8a0e0f7f2f9cd5fb69899b5d7037bc969df4339 (diff)
Merge branch 'overdrive-master'HEADmain
Diffstat (limited to '2020-overdrive/src/main.rs')
-rw-r--r--2020-overdrive/src/main.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/2020-overdrive/src/main.rs b/2020-overdrive/src/main.rs
new file mode 100644
index 0000000..c5f7857
--- /dev/null
+++ b/2020-overdrive/src/main.rs
@@ -0,0 +1,24 @@
+use std::io::prelude::*;
+use std::io::stdin;
+
+use vroomba::command::Command;
+use vroomba::*;
+
+fn main() {
+ for line in stdin().lock().lines() {
+ let round_number = line
+ .expect("Failed to read line from stdin: {}")
+ .parse::<usize>()
+ .expect("Round number was not an unsigned integer: {}");
+ let command =
+ match json::read_state_from_json_file(&format!("./rounds/{}/state.json", round_number))
+ {
+ Ok(state) => choose_command(round_number, &state),
+ Err(e) => {
+ eprintln!("WARN: State file could not be parsed: {}", e);
+ Command::Nothing
+ }
+ };
+ println!("C;{};{}", round_number, command);
+ }
+}