From de0da386aefa446ac78ee1aff6e2d4fb5a32d34f Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Tue, 8 Dec 2020 10:08:19 -0800 Subject: [PATCH] Updated day8 so it's not reliant on all op codes being 3 chars long --- 2020/day8.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2020/day8.cpp b/2020/day8.cpp index ad82b0f..1b389d2 100644 --- a/2020/day8.cpp +++ b/2020/day8.cpp @@ -40,7 +40,7 @@ auto extract_op(const std::string & string) -> Op { else if (string.substr(0, 3) == "jmp") { op.code = Jmp; } else if (string.substr(0, 3) == "nop") { op.code = Nop; } - op.num = std::stoi(string.substr(4, string.size() - 4)); + op.num = std::stoi(string.substr(string.find(" ") + 1, string.size() - 4)); return op; }