Skip to content

Commit

Permalink
cpp + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
96-LB committed Dec 19, 2020
1 parent a75a733 commit 309d9b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
10 changes: 2 additions & 8 deletions 10 - Inventory/3.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
8
10
76
1
695
0
43
24
103
10
1 2 3 4 5 6 7 8 9 10
6 changes: 3 additions & 3 deletions 12 - Delivery Duplication/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,4 +18,4 @@
if not duplicates: #if there are no duplicates
duplicates.append('NONE')

print(''.join(duplicates))
print('\n'.join(duplicates))
24 changes: 17 additions & 7 deletions judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.'):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 309d9b9

Please sign in to comment.