From 309d9b979655b01ae9eb5b66bba2680447779cae Mon Sep 17 00:00:00 2001 From: 96-LB Date: Sat, 19 Dec 2020 14:28:14 -0500 Subject: [PATCH] cpp + fixes --- 10 - Inventory/3.txt | 10 ++-------- 12 - Delivery Duplication/main.py | 6 +++--- judge.py | 24 +++++++++++++++++------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/10 - Inventory/3.txt b/10 - Inventory/3.txt index a18055c..4257051 100644 --- a/10 - Inventory/3.txt +++ b/10 - Inventory/3.txt @@ -1,9 +1,3 @@ -8 -10 -76 1 -695 -0 -43 -24 -103 \ No newline at end of file +10 +1 2 3 4 5 6 7 8 9 10 \ No newline at end of file diff --git a/12 - Delivery Duplication/main.py b/12 - Delivery Duplication/main.py index 8195d5f..f8bd1e1 100644 --- a/12 - Delivery Duplication/main.py +++ b/12 - Delivery Duplication/main.py @@ -3,12 +3,12 @@ length = sys.stdin.readline() old = [] #the addresses from last week for i in range(int(length)): - old.append(sys.stdin.readline()) + old.append(input()) #input will ignore the newline length = sys.stdin.readline() new = [] #the addresses from this week for i in range(int(length)): - new.append(sys.stdin.readline()) + new.append(input()) duplicates = [] #the duplicate addresses for i in old: #loops over the old address list @@ -18,4 +18,4 @@ if not duplicates: #if there are no duplicates duplicates.append('NONE') -print(''.join(duplicates)) +print('\n'.join(duplicates)) diff --git a/judge.py b/judge.py index 9ab4676..ca3529d 100644 --- a/judge.py +++ b/judge.py @@ -2,16 +2,22 @@ file = sys.argv[1] if len(sys.argv) > 1 else input('Filename?') extension = file.split('.')[-1].lower() if '.' in file else '' -language = extension if extension in ['py', 'java', 'class'] else input('Language?').lower() +language = extension if extension in ['py', 'java', 'class', 'cpp', 'exe'] else input('Language?').lower() problem = input('Problem?') def get_args(): + global file if language in ['python', 'py', 'python3', 'py3']: return ['py', file] if language in ['java']: subprocess.run(['javac', file], capture_output=True, text=True, check=True) if language in ['java', 'class']: return ['java', '.'.join(file.split('.')[:-1])] + if language in ['cpp', 'c++']: + subprocess.run(['g++', file], capture_output=True, text=True, check=True) + file = 'a.exe' + if language in ['cpp', 'c++', 'app', 'exe', 'executable']: + return [file] verdict = 'Something went wrong' for i in os.listdir('.'): @@ -46,14 +52,18 @@ def get_args(): except subprocess.TimeoutExpired as e: v = 'T' process = e - except subprocess.CalledProcessError as e: + except (subprocess.CalledProcessError, IndexError) as e: v = 'E' process = e - b = [k.strip() for k in (process.stdout or '').splitlines() if k.strip()] - with open(f'!LOGS/{j}.out', 'w') as g: - g.write(process.stdout or '') - with open(f'!LOGS/{j}.err', 'w') as g: - g.write(process.stderr or '') + b = None + try: + b = [k.strip() for k in (process.stdout or '').splitlines() if k.strip()] + with open(f'!LOGS/{j}.out', 'w') as g: + g.write(process.stdout or '') + with open(f'!LOGS/{j}.err', 'w') as g: + g.write(process.stderr or '') + except AttributeError as e: + pass if a == b: v = 'A' verdict += v