From f8a0e0f7f2f9cd5fb69899b5d7037bc969df4339 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 19 Apr 2022 21:36:41 +0200 Subject: Refile for merging repos --- 2020-overdrive/src/main.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 2020-overdrive/src/main.rs (limited to '2020-overdrive/src/main.rs') 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::() + .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); + } +} -- cgit v1.2.3