]> Skullheadx's Git Forge - CCC.git/commitdiff
2018 S1 + grader upd
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Thu, 5 Jan 2023 03:36:36 +0000 (22:36 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Thu, 5 Jan 2023 03:36:36 +0000 (22:36 -0500)
Main/Python/2018/S1.py [new file with mode: 0644]
Main/Python/__pycache__/tester.cpython-310.pyc
Main/Python/grader.py

diff --git a/Main/Python/2018/S1.py b/Main/Python/2018/S1.py
new file mode 100644 (file)
index 0000000..310fccf
--- /dev/null
@@ -0,0 +1,27 @@
+from queue import PriorityQueue
+
+def halfway_length(a,b):
+    return abs(a-b)/2
+
+
+N = int(input())
+
+q = PriorityQueue()
+
+for i in range(N):
+    V = int(input())
+    q.put(V)
+
+prev = q.get()
+prev_length = 1000000000
+smallest_length = None
+while not q.empty():
+    current = q.get()
+    d = halfway_length(current, prev)
+    prev_length += d
+    if smallest_length is None or prev_length < smallest_length:
+        smallest_length = prev_length
+    prev_length = d
+    prev = current
+
+print(smallest_length)
\ No newline at end of file
index ac1869574d9f3d4d65c00973b571decad159053c..cde2f625f4b4ac25e79c2750fd8dc8faf02092d3 100644 (file)
Binary files a/Main/Python/__pycache__/tester.cpython-310.pyc and b/Main/Python/__pycache__/tester.cpython-310.pyc differ
index a55c7756bd41865620e17b3852d6b3017b289314..226ffc8060cb76c3e6932871f3d402265b8f4514 100644 (file)
@@ -14,10 +14,10 @@ class Capturing(list):
         sys.stdout = self._stdout
 
 
-PATH = "2012/"
+PATH = "2018/"
 PROBLEM = "S1"
 
-test_input_path = os.path.join(PATH, f"windows_data/senior/{PROBLEM}/")
+test_input_path = os.path.join(PATH, f"senior/{PROBLEM}/")
 
 test_inputs = []
 test_outputs = []
@@ -45,6 +45,8 @@ for test_input, test_output in zip(test_inputs, test_outputs):
         print(f"Test Failed. {round(end - start, 3)}s")
         print(f"{test_input = }")
         print(f"{test_output = }")
+        print(f"{output = }")
+        print()
 
 print("--------------------------------")
 print(f"Tests passed: {correct}/{total}")
\ No newline at end of file