From 2d7c7fc2811fdef083c2e258bf93b09418fb6aba Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Tue, 19 Sep 2017 18:00:14 +0300 Subject: [PATCH 01/12] compile options and some more languages support added (also renamed default ./a.out -> ./ProblemName ) --- acedit/util.py | 77 +++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 28beb23..28920da 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -7,7 +7,8 @@ import requests as rq import grequests as grq from argparse import ArgumentParser -except: +except ImportError as e: + print e err = """ You haven't installed the required dependencies. Run 'python setup.py install' to install the dependencies. @@ -296,50 +297,29 @@ def run_solution(args): num_cases = len(os.listdir(testcases_path)) / 2 results, expected_outputs, user_outputs = [], [], [] - if extension == 'py': - - for i in xrange(num_cases): - status = os.system('cat ' + os.path.join(testcases_path, 'Input' + str( - i)) + ' | timeout 3s python \'' + problem_path + '.py\' > temp_output' + str(i)) - if status == 124: - # Time Limit Exceeded - results += [Utilities.colors['BOLD'] + - Utilities.colors['YELLOW'] + 'TLE' + Utilities.colors['ENDC']] - - elif status == 0: - # Ran successfully - with open('temp_output' + str(i), 'r') as temp_handler, open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler: - expected_output = out_handler.read().strip().split('\n') - user_output = temp_handler.read().strip().split('\n') - - expected_output = '\n'.join( - [line.strip() for line in expected_output]) - user_output = '\n'.join( - [line.strip() for line in user_output]) - - expected_outputs += [expected_output] - user_outputs += [user_output] - - if expected_output == user_output: - # All Correct - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'GREEN'] + 'AC' + Utilities.colors['ENDC']] - else: - # Wrong Answer - results += [Utilities.colors['BOLD'] + - Utilities.colors['RED'] + 'WA' + Utilities.colors['ENDC']] - - else: - # Runtime Error - results += [Utilities.colors['BOLD'] + - Utilities.colors['RED'] + 'RTE' + Utilities.colors['ENDC']] - - elif extension in ['c', 'cpp', 'java']: - - compiler = {'c': 'gcc', 'cpp': 'g++', 'java': 'javac -d .'}[extension] - execute_command = {'c': './a.out', 'cpp': './a.out', 'java': 'java ' + basename}[extension] - compile_status = os.system( - compiler + ' \'' + problem_path + '.' + extension + '\'') + if extension in ['c', 'cpp', 'java', 'py', 'hs']: + + compiler = { + 'hs': 'ghc --make -O -dynamic -o ' + basename, + 'py': None, + 'rb': None, + 'c': 'gcc -static -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' + basename, + 'cpp': 'g++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, + 'java': 'javac -d .' + }[extension] + print compiler + execute_command = { + 'py': 'python ' + basename + '.' + extension, + 'rb': 'ruby ' + basename + '.' + extension, + 'hs': './' + basename, + 'c': './' + basename, + 'cpp': './' + basename, + 'java': 'java -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US ' + basename + }[extension] + if compiler is None: + compile_status = 0 + else: + compile_status = os.system(compiler + ' \'' + problem_path + '.' + extension + '\'') if compile_status == 0: @@ -396,6 +376,13 @@ def run_solution(args): inputs = Utilities.input_file_to_string(testcases_path, num_cases) + if len(expected_outputs) == 0: + # Compilation error occurred + message = Utilities.colors['BOLD'] + Utilities.colors[ + 'RED'] + 'Something bad happened. Not run against test cases' + Utilities.colors['ENDC'] + '.' + print message + sys.exit(0) + for i in xrange(num_cases): row = [ From 306a01659f681eb1d80ae63f1b1f4ca48362de5b Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Tue, 19 Sep 2017 18:07:26 +0300 Subject: [PATCH 02/12] debug info deleted --- acedit/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 28920da..50ce968 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -7,8 +7,7 @@ import requests as rq import grequests as grq from argparse import ArgumentParser -except ImportError as e: - print e +except: err = """ You haven't installed the required dependencies. Run 'python setup.py install' to install the dependencies. From adcfd44c4dec13a357cba3d92ea55913b1a53543 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 09:56:53 +0300 Subject: [PATCH 03/12] debug info deleted, rb in extensions --- acedit/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 50ce968..3e3c187 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -296,17 +296,16 @@ def run_solution(args): num_cases = len(os.listdir(testcases_path)) / 2 results, expected_outputs, user_outputs = [], [], [] - if extension in ['c', 'cpp', 'java', 'py', 'hs']: + if extension in ['c', 'cpp', 'java', 'py', 'hs', 'rb']: compiler = { 'hs': 'ghc --make -O -dynamic -o ' + basename, 'py': None, 'rb': None, 'c': 'gcc -static -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' + basename, - 'cpp': 'g++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, + 'cpp': 'clang++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, 'java': 'javac -d .' }[extension] - print compiler execute_command = { 'py': 'python ' + basename + '.' + extension, 'rb': 'ruby ' + basename + '.' + extension, From 4f2bb04557965d578b811680b83d80893816d17d Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 10:07:23 +0300 Subject: [PATCH 04/12] RTE and TLE cases are handled correctly --- acedit/util.py | 72 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 3e3c187..a913cfa 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -325,38 +325,40 @@ def run_solution(args): for i in xrange(num_cases): status = os.system('timeout 2s ' + execute_command + ' < ' + os.path.join( testcases_path, 'Input' + str(i)) + ' > temp_output' + str(i)) - if status == 124: - # Time Limit Exceeded - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'YELLOW'] + 'TLE' + Utilities.colors['ENDC']] - - elif status == 0: - # Ran successfully - with open('temp_output' + str(i), 'r') as temp_handler, open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler: - expected_output = out_handler.read().strip().split('\n') - user_output = temp_handler.read().strip().split('\n') - - expected_output = '\n'.join( - [line.strip() for line in expected_output]) - user_output = '\n'.join( - [line.strip() for line in user_output]) - - expected_outputs += [expected_output] - user_outputs += [user_output] - - if expected_output == user_output: - # All Correct + with open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler: + expected_output = out_handler.read().strip().split('\n') + expected_output = '\n'.join( + [line.strip() for line in expected_output]) + expected_outputs += [expected_output] + + if status == 124: + # Time Limit Exceeded results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'GREEN'] + 'AC' + Utilities.colors['ENDC']] - else: - # Wrong Answer - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'RED'] + 'WA' + Utilities.colors['ENDC']] + 'YELLOW'] + 'TLE' + Utilities.colors['ENDC']] + user_outputs += [''] + + elif status == 0: + # Ran successfully + with open('temp_output' + str(i), 'r') as temp_handler: + user_output = temp_handler.read().strip().split('\n') + user_output = '\n'.join( + [line.strip() for line in user_output]) + user_outputs += [user_output] + + if expected_output == user_output: + # All Correct + results += [Utilities.colors['BOLD'] + Utilities.colors[ + 'GREEN'] + 'AC' + Utilities.colors['ENDC']] + else: + # Wrong Answer + results += [Utilities.colors['BOLD'] + Utilities.colors[ + 'RED'] + 'WA' + Utilities.colors['ENDC']] - else: - # Runtime Error - results += [Utilities.colors['BOLD'] + - Utilities.colors['RED'] + 'RTE' + Utilities.colors['ENDC']] + else: + # Runtime Error + results += [Utilities.colors['BOLD'] + + Utilities.colors['RED'] + 'RTE' + Utilities.colors['ENDC']] + user_outputs += [''] else: # Compilation error occurred message = Utilities.colors['BOLD'] + Utilities.colors[ @@ -374,12 +376,12 @@ def run_solution(args): inputs = Utilities.input_file_to_string(testcases_path, num_cases) - if len(expected_outputs) == 0: + # if len(expected_outputs) == 0: # Compilation error occurred - message = Utilities.colors['BOLD'] + Utilities.colors[ - 'RED'] + 'Something bad happened. Not run against test cases' + Utilities.colors['ENDC'] + '.' - print message - sys.exit(0) + # message = Utilities.colors['BOLD'] + Utilities.colors[ + # 'RED'] + 'Something bad happened. Not run against test cases' + Utilities.colors['ENDC'] + '.' + # print message + # sys.exit(0) for i in xrange(num_cases): From 5fe467a88eb6e4e444b4cf2ea9098f772ef046dc Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 10:08:57 +0300 Subject: [PATCH 05/12] deleted useless comment --- acedit/util.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index a913cfa..aab8b10 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -376,13 +376,6 @@ def run_solution(args): inputs = Utilities.input_file_to_string(testcases_path, num_cases) - # if len(expected_outputs) == 0: - # Compilation error occurred - # message = Utilities.colors['BOLD'] + Utilities.colors[ - # 'RED'] + 'Something bad happened. Not run against test cases' + Utilities.colors['ENDC'] + '.' - # print message - # sys.exit(0) - for i in xrange(num_cases): row = [ From 1a7f4c7ca608c2872747e04e423753224677fb32 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 10:23:15 +0300 Subject: [PATCH 06/12] forgot to change clang++ to g++ --- acedit/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acedit/util.py b/acedit/util.py index aab8b10..aef6126 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -303,7 +303,7 @@ def run_solution(args): 'py': None, 'rb': None, 'c': 'gcc -static -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' + basename, - 'cpp': 'clang++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, + 'cpp': 'g++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, 'java': 'javac -d .' }[extension] execute_command = { From 2478c1d0159c2def2e5b9ac5174d71561dc3b00e Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 12:53:52 +0300 Subject: [PATCH 07/12] add-test --- acedit/util.py | 64 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index aef6126..e3b2a4d 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -53,6 +53,11 @@ def parse_flags(supported_sites): action='store_true', help='Force download the test cases, even if they are cached') + parser.add_argument('--add-test', + dest='add_test', + action='store_true', + help='Add test to specific problem of contest') + parser.add_argument('--run', dest='source_file', help='Name of source file to be run') @@ -103,6 +108,7 @@ def parse_flags(supported_sites): flags['source'] = args.source_file flags['default_site'] = args.default_site flags['default_contest'] = args.default_contest + flags['add_test'] = args.add_test return flags @@ -162,6 +168,28 @@ def clear_cache(site): os.makedirs(os.path.join(Utilities.cache_dir, site)) print 'Done.' + @staticmethod + def get_long_input(message): + print message + lines = [] + while True: + try: + line = raw_input() + if line == '' and len(lines) > 0 and lines[-1] == '': + break + except EOFError: + lines.append('') + break + lines.append(line) + return '\n'.join(lines) + + @staticmethod + def add_test(args): + inputs = [Utilities.get_long_input('Specify input (^D or two consecutive empty lines to stop):')] + outputs = [Utilities.get_long_input('Specify output (^D or two consecutive empty lines to stop):')] + is_in_cache = Utilities.check_cache(args['site'], args['contest'], args['problem']) + Utilities.store_files(args['site'], args['contest'], args['problem'], inputs, outputs) + @staticmethod def store_files(site, contest, problem, inputs, outputs): """ @@ -170,33 +198,36 @@ def store_files(site, contest, problem, inputs, outputs): # Handle case for SPOJ specially as it does not have contests contest = '' if site == 'spoj' else contest + testcases_path = os.path.join(Utilities.cache_dir, site, contest, problem) + num_cases = len(os.listdir(testcases_path)) / 2 for i, inp in enumerate(inputs): - filename = os.path.join( - Utilities.cache_dir, site, contest, problem, 'Input' + str(i)) + filename = os.path.join(testcases_path, 'Input' + str(i + num_cases)) with open(filename, 'w') as handler: handler.write(inp) for i, out in enumerate(outputs): - filename = os.path.join( - Utilities.cache_dir, site, contest, problem, 'Output' + str(i)) + filename = os.path.join(testcases_path, 'Output' + str(i + num_cases)) with open(filename, 'w') as handler: handler.write(out) @staticmethod - def download_problem_testcases(args): - """ - Download test cases for a given problem - """ + def get_platform(args): if args['site'] == 'codeforces': - platform = Codeforces(args) + return Codeforces(args) elif args['site'] == 'codechef': - platform = Codechef(args) + return Codechef(args) elif args['site'] == 'spoj': - platform = Spoj(args) + return Spoj(args) else: - platform = Hackerrank(args) + return Hackerrank(args) + @staticmethod + def download_problem_testcases(args): + """ + Download test cases for a given problem + """ + platform = Utilities.get_platform(args) is_in_cache = Utilities.check_cache( platform.site, platform.contest, platform.problem) @@ -211,13 +242,7 @@ def download_contest_testcases(args): """ Download test cases for all problems in a given contest """ - if args['site'] == 'codeforces': - platform = Codeforces(args) - elif args['site'] == 'codechef': - platform = Codechef(args) - elif args['site'] == 'hackerrank': - platform = Hackerrank(args) - + platform = Utilities.get_platform(args) Utilities.check_cache( platform.site, platform.contest, platform.problem) @@ -330,7 +355,6 @@ def run_solution(args): expected_output = '\n'.join( [line.strip() for line in expected_output]) expected_outputs += [expected_output] - if status == 124: # Time Limit Exceeded results += [Utilities.colors['BOLD'] + Utilities.colors[ From ae55deb8f0621d503eba17e3486054b36c693969 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 20 Sep 2017 13:29:59 +0300 Subject: [PATCH 08/12] add-test (main), colors, info --- acedit/main.py | 8 ++++++ acedit/util.py | 76 ++++++++++++++++++++++++++------------------------ 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/acedit/main.py b/acedit/main.py index f3c533a..d13583a 100644 --- a/acedit/main.py +++ b/acedit/main.py @@ -16,6 +16,10 @@ def validate_args(args): if args['clear_cache']: return + if args['add_test'] and (not args['contest'] and args['site'] != 'spoj' or not args['problem']): + print 'Please specify contest and problem code' + sys.exit(0) + if not args['site'] == 'spoj' and args['contest'] is None: print 'Please specify contest code or set a default contest.' sys.exit(0) @@ -37,6 +41,10 @@ def main(): # set default site util.Utilities.set_constants('default_site', args['default_site']) + elif args['add_test']: + # adding test + util.Utilities.add_test(args) + elif args['default_contest']: # set default contest util.Utilities.set_constants('default_contest', args['default_contest']) diff --git a/acedit/util.py b/acedit/util.py index e3b2a4d..ed66013 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -26,6 +26,12 @@ class Utilities: 'ENDC': '\033[0m', 'BOLD': '\033[1m', } + verdicts = { + 'AC': colors['BOLD'] + colors['GREEN'] + 'AC' + colors['ENDC'], + 'WA': colors['BOLD'] + colors['RED'] + 'WA' + colors['ENDC'], + 'RTE': colors['BOLD'] + colors['RED'] + 'RTE' + colors['ENDC'], + 'TLE': colors['BOLD'] + colors['YELLOW'] + 'TLE' + colors['ENDC'] + } @staticmethod def parse_flags(supported_sites): @@ -185,10 +191,12 @@ def get_long_input(message): @staticmethod def add_test(args): + print 'Adding new test to %s (contest: %s, problem: %s)' % (args['site'], args['contest'], args['problem']) inputs = [Utilities.get_long_input('Specify input (^D or two consecutive empty lines to stop):')] outputs = [Utilities.get_long_input('Specify output (^D or two consecutive empty lines to stop):')] is_in_cache = Utilities.check_cache(args['site'], args['contest'], args['problem']) Utilities.store_files(args['site'], args['contest'], args['problem'], inputs, outputs) + print 'Test is successfully added' @staticmethod def store_files(site, contest, problem, inputs, outputs): @@ -295,6 +303,36 @@ def handle_kbd_interrupt(site, contest, problem): print 'Done. Exiting gracefully.' + @staticmethod + def run_command_on_one_test(testcases_path, testcase_number, execute_command): + status = os.system('timeout 2s ' + execute_command + ' < ' + os.path.join( + testcases_path, 'Input' + str(testcase_number)) + ' > temp_output' + str(testcase_number)) + user_output = '' + with open(os.path.join(testcases_path, 'Output' + str(testcase_number)), 'r') as out_handler: + expected_output = out_handler.read().strip().split('\n') + expected_output = '\n'.join([line.strip() for line in expected_output]) + if status == 124: + # Time Limit Exceeded + results = Utilities.verdicts['TLE'] + + elif status == 0: + # Ran successfully + with open('temp_output' + str(testcase_number), 'r') as temp_handler: + user_output = temp_handler.read().strip().split('\n') + user_output = '\n'.join([line.strip() for line in user_output]) + + if expected_output == user_output: + # All Correct + results = Utilities.verdicts['AC'] + else: + # Wrong Answer + results = Utilities.verdicts['WA'] + + else: + # Runtime Error + results = Utilities.verdicts['RTE'] + return (expected_output, user_output, results) + @staticmethod def run_solution(args): """ @@ -319,7 +357,7 @@ def run_solution(args): if os.path.isdir(testcases_path): num_cases = len(os.listdir(testcases_path)) / 2 - results, expected_outputs, user_outputs = [], [], [] + results, expected_outputs, user_outputs = [''] * num_cases, [''] * num_cases, [''] * num_cases if extension in ['c', 'cpp', 'java', 'py', 'hs', 'rb']: @@ -348,41 +386,7 @@ def run_solution(args): # Compiled successfully for i in xrange(num_cases): - status = os.system('timeout 2s ' + execute_command + ' < ' + os.path.join( - testcases_path, 'Input' + str(i)) + ' > temp_output' + str(i)) - with open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler: - expected_output = out_handler.read().strip().split('\n') - expected_output = '\n'.join( - [line.strip() for line in expected_output]) - expected_outputs += [expected_output] - if status == 124: - # Time Limit Exceeded - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'YELLOW'] + 'TLE' + Utilities.colors['ENDC']] - user_outputs += [''] - - elif status == 0: - # Ran successfully - with open('temp_output' + str(i), 'r') as temp_handler: - user_output = temp_handler.read().strip().split('\n') - user_output = '\n'.join( - [line.strip() for line in user_output]) - user_outputs += [user_output] - - if expected_output == user_output: - # All Correct - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'GREEN'] + 'AC' + Utilities.colors['ENDC']] - else: - # Wrong Answer - results += [Utilities.colors['BOLD'] + Utilities.colors[ - 'RED'] + 'WA' + Utilities.colors['ENDC']] - - else: - # Runtime Error - results += [Utilities.colors['BOLD'] + - Utilities.colors['RED'] + 'RTE' + Utilities.colors['ENDC']] - user_outputs += [''] + expected_outputs[i], user_outputs[i], results[i] = Utilities.run_command_on_one_test(testcases_path, i, execute_command) else: # Compilation error occurred message = Utilities.colors['BOLD'] + Utilities.colors[ From 1ccc01d4e78dab8e11c5e9c933bcc95235436859 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 25 Oct 2017 18:04:41 +0300 Subject: [PATCH 09/12] gym for codeforces support --- acedit/util.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 28920da..aeddda5 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -260,14 +260,14 @@ def handle_kbd_interrupt(site, contest, problem): # Handle case for SPOJ specially as it does not have contests contest = '' if site == 'spoj' else contest - if problem is not None: - path = os.path.join(Utilities.cache_dir, site, contest, problem) - if os.path.isdir(path): - rmtree(path) - else: - path = os.path.join(Utilities.cache_dir, site, contest) - if os.path.isdir(path): - rmtree(path) + # if problem is not None: + # path = os.path.join(Utilities.cache_dir, site, contest, problem) + # if os.path.isdir(path): + # rmtree(path) + # else: + # path = os.path.join(Utilities.cache_dir, site, contest) + # if os.path.isdir(path): + # rmtree(path) print 'Done. Exiting gracefully.' @@ -530,8 +530,8 @@ def scrape_problem(self): Method to scrape a single problem from codeforces """ print 'Fetching problem ' + self.contest + '-' + self.problem + ' from Codeforces...' - url = 'http://codeforces.com/contest/' + \ - self.contest + '/problem/' + self.problem + type = 'contest' if int(self.contest) <= 100000 else 'gym' + url = 'http://codeforces.com/%s/%s/problem/%s' % (type, self.contest, self.problem) req = Utilities.get_html(url) inputs, outputs = self.parse_html(req) Utilities.store_files(self.site, self.contest, @@ -543,7 +543,8 @@ def scrape_contest(self): Method to scrape all problems from a given codeforces contest """ print 'Checking problems available for contest ' + self.contest + '...' - url = 'http://codeforces.com/contest/' + self.contest + type = 'contest' if int(self.contest) <= 100000 else 'gym' + url = 'http://codeforces.com/%s/%s' % (type, self.contest) req = Utilities.get_html(url) links = self.get_problem_links(req) From 333c2986bcf6f2dae2e5c7e059a974208d8ee91f Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Sun, 28 Apr 2019 00:56:03 +0300 Subject: [PATCH 10/12] c++17 --- acedit/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acedit/util.py b/acedit/util.py index ed66013..f507c17 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -366,7 +366,7 @@ def run_solution(args): 'py': None, 'rb': None, 'c': 'gcc -static -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' + basename, - 'cpp': 'g++ -static -DONLINE_JUDGE -lm -s -x c++ -O2 -std=c++14 -o ' + basename, + 'cpp': 'clang++ -static -DONLINE_JUDGE -lm -s -x c++ -include /home/igorjan/206round/bits.h -O2 -std=c++17 -o ' + basename, 'java': 'javac -d .' }[extension] execute_command = { From 299870464774d48980b151c8150f6c5b0b90fc42 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Wed, 4 Sep 2019 01:39:27 +0300 Subject: [PATCH 11/12] kotlin --- acedit/util.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index f507c17..2c8b458 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -359,14 +359,15 @@ def run_solution(args): num_cases = len(os.listdir(testcases_path)) / 2 results, expected_outputs, user_outputs = [''] * num_cases, [''] * num_cases, [''] * num_cases - if extension in ['c', 'cpp', 'java', 'py', 'hs', 'rb']: + if extension in ['c', 'cpp', 'java', 'py', 'hs', 'rb', 'kt']: compiler = { 'hs': 'ghc --make -O -dynamic -o ' + basename, 'py': None, 'rb': None, 'c': 'gcc -static -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' + basename, - 'cpp': 'clang++ -static -DONLINE_JUDGE -lm -s -x c++ -include /home/igorjan/206round/bits.h -O2 -std=c++17 -o ' + basename, + 'cpp': 'clang++ -DONLINE_JUDGE -lm -s -x c++ -include /home/igorjan/206round/bits.h -O2 -std=c++17 -o ' + basename, + 'kt': 'kotlinc -d .', 'java': 'javac -d .' }[extension] execute_command = { @@ -375,6 +376,7 @@ def run_solution(args): 'hs': './' + basename, 'c': './' + basename, 'cpp': './' + basename, + 'kt': 'kotlin -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US ' + basename + 'Kt', 'java': 'java -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US ' + basename }[extension] if compiler is None: @@ -395,7 +397,7 @@ def run_solution(args): sys.exit(0) else: - print 'Supports only C, C++, Python and Java as of now.' + print 'Supports only C, C++, Python, Kotlin and Java as of now.' sys.exit(0) from terminaltables import AsciiTable From 8e7f8fc9aa99120ce02b1e8bb1b1ae78fcc68593 Mon Sep 17 00:00:00 2001 From: igorjan94 Date: Sat, 21 Sep 2019 22:49:46 +0300 Subject: [PATCH 12/12] extra spaces deleted --- acedit/util.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/acedit/util.py b/acedit/util.py index 2c8b458..c6bbe5e 100644 --- a/acedit/util.py +++ b/acedit/util.py @@ -489,17 +489,17 @@ def parse_html(self, req): formatted_inputs, formatted_outputs = [], [] - for inp in inputs: + def getContent(inp): pre = inp.find('pre').decode_contents() pre = reduce(lambda a, kv: a.replace(*kv), repls, pre) pre = re.sub('<[^<]+?>', '', pre) - formatted_inputs += [pre] + return re.sub(r'^\s*', '', pre) + + for inp in inputs: + formatted_inputs += [getContent(inp)] for out in outputs: - pre = out.find('pre').decode_contents() - pre = reduce(lambda a, kv: a.replace(*kv), repls, pre) - pre = re.sub('<[^<]+?>', '', pre) - formatted_outputs += [pre] + formatted_outputs += [getContent(out)] # print 'Inputs', formatted_inputs # print 'Outputs', formatted_outputs