From: Skullheadx <704277@pdsb.net> Date: Fri, 6 Jan 2023 23:24:03 +0000 (-0500) Subject: 2012 S2 X-Git-Url: http://git.skullheadx.com/nixos/blog/openbsd_html_css.html?a=commitdiff_plain;h=019313e7419bac179d09d3fcf37dff69f5d87358;p=CCC.git 2012 S2 --- 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 cde2f62..ac18695 100644 Binary files a/Main/Python/__pycache__/tester.cpython-310.pyc and b/Main/Python/__pycache__/tester.cpython-310.pyc differ 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}/")