From 019313e7419bac179d09d3fcf37dff69f5d87358 Mon Sep 17 00:00:00 2001 From: Skullheadx <704277@pdsb.net> Date: Fri, 6 Jan 2023 18:24:03 -0500 Subject: [PATCH] 2012 S2 --- Main/Python/2012/S2.py | 19 ++++++++++++++++++ .../Python/__pycache__/tester.cpython-310.pyc | Bin 438 -> 416 bytes Main/Python/grader.py | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Main/Python/2012/S2.py diff --git a/Main/Python/2012/S2.py b/Main/Python/2012/S2.py new file mode 100644 index 0000000..2790998 --- /dev/null +++ b/Main/Python/2012/S2.py @@ -0,0 +1,19 @@ +n = input() + +roman = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} + +total = 0 + +for i in range(0, len(n), 2): + A, R = int(n[i]), roman[n[i + 1]] + if i < len(n)-2: + nR = roman[n[i + 3]] + else: + nR = 0 + if nR > R: + total -= A * R + else: + total += A * R + + +print(total) diff --git a/Main/Python/__pycache__/tester.cpython-310.pyc b/Main/Python/__pycache__/tester.cpython-310.pyc index cde2f625f4b4ac25e79c2750fd8dc8faf02092d3..ac1869574d9f3d4d65c00973b571decad159053c 100644 GIT binary patch delta 33 pcmdnSynvZIpO=@5fq{Wx!oRH>x%n75lwGW1+%rouCYv+X0|1Pr2;=|& delta 55 zcmZ3$yp5SVpO=@5fq{Xc)_L1TZazjiOJ}Q?(Bjmh;+Vvg-2A*4m;B_?+|<01;u!bL K5|7D>jP(Gbmk{#+ diff --git a/Main/Python/grader.py b/Main/Python/grader.py index 226ffc8..268564e 100644 --- a/Main/Python/grader.py +++ b/Main/Python/grader.py @@ -14,8 +14,8 @@ class Capturing(list): sys.stdout = self._stdout -PATH = "2018/" -PROBLEM = "S1" +PATH = "2012/" +PROBLEM = "S2" test_input_path = os.path.join(PATH, f"senior/{PROBLEM}/") -- 2.54.0