]> Skullheadx's Git Forge - CCC.git/commitdiff
2012 S2
authorSkullheadx <704277@pdsb.net>
Fri, 6 Jan 2023 23:24:03 +0000 (18:24 -0500)
committerSkullheadx <704277@pdsb.net>
Fri, 6 Jan 2023 23:24:03 +0000 (18:24 -0500)
Main/Python/2012/S2.py [new file with mode: 0644]
Main/Python/__pycache__/tester.cpython-310.pyc
Main/Python/grader.py

diff --git a/Main/Python/2012/S2.py b/Main/Python/2012/S2.py
new file mode 100644 (file)
index 0000000..2790998
--- /dev/null
@@ -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)
index cde2f625f4b4ac25e79c2750fd8dc8faf02092d3..ac1869574d9f3d4d65c00973b571decad159053c 100644 (file)
Binary files a/Main/Python/__pycache__/tester.cpython-310.pyc and b/Main/Python/__pycache__/tester.cpython-310.pyc differ
index 226ffc8060cb76c3e6932871f3d402265b8f4514..268564eadc4eba5d3e568f0613ad9fd5a4402cea 100644 (file)
@@ -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}/")