Skip to content

Commit

Permalink
HackerEarth Added (#63)
Browse files Browse the repository at this point in the history
* hackerearth added

* hackerearth

* checker.py edited

* input folder deleted

* folders merged
  • Loading branch information
ahegde3 authored and aashutoshrathi committed Mar 20, 2019
1 parent 3fc07dd commit fdb3515
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tc_generator/checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import os
import random
import shutil
import sys
import timeit
import zipfile
import subprocess
import math

from lang_compiler import LANGS

if sys.version[0] == '3':
INPUT = input
XRange = range

try:
os.mkdir('input')
os.mkdir('output')
except OSError:
pass


def user(choice, i):
#add code to execute users program
'''try:
pass #users program has to be executed
except Exception:
print("Looks like you don't have {0} :/ \nYou can refer to {1} for help.".format(
LANGS[choice - 1]['req'], LANGS[choice - 1]['link']))
'''



def generate(choice, i):
try:
return (subprocess.check_output('%s < input/input%02d.txt' %
(LANGS[3]['command'], 2),shell=True))

except Exception:
print("Looks like you don't have {0} :/ \nYou can refer to {1} for help.".format(
LANGS[choice - 1]['req'], LANGS[choice - 1]['link']))



'''
def main():
# Get input from Input Test Files
N = int(raw_input()
assert(N >= 1 and N <= 1000000)
s = map(int, raw_input().split())
assert(len(s) == N)
# Get output produced by User's code
user_result = int(raw_input()
# Write your logic to check if user's result is correct. Assert false if not.
score = 10 # Score for this test file
print score
'''
def main():
#f=open('input2/input01.txt', 'r')
t=10
score=10
res=0
for i in range(0,t+1):
m=generate(4,i)

n=user(4,i) #this function will execute users logic.



if m==n:res+=score
# if assertion failed it will fail for the given testcase
#f.close()
print(res)


# Always invoke by main. It is necessary for checker to be invoked by main()
if __name__ == '__main__':
main()
64 changes: 64 additions & 0 deletions tc_generator/tc_gen_hackerearth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'''
Aashutosh Rathi
https://github.com/aashutoshrathi/
Testcase Generator for HackerRank
'''
from __future__ import print_function

import os
import random
import shutil
import sys
import timeit
import zipfile

import math

from lang_compiler import LANGS

if sys.version[0] == '3':
INPUT = input
XRange = range

try:
os.mkdir('input')

except OSError:
pass

POWER = math.pow
RINT = random.randint


def main():
choice = int(INPUT("Enter your choice of language\n1. C\n2. C++\n3. Java\n4. Python\n5. C#\n6. Go\n"))
if choice not in range(1, 7):
print("Wrong choice entered!")
exit()

test_files = 10 # number of test files, change it according to you.

for i in XRange(0, test_files + 1):
print('Generating:', i, file=sys.stderr)
sys.stdout = open('input/input%02d.txt' % i, 'w')

'''
Input area will start here,
everything that you print out here will be taken as input in your logic file.
'''

# Input File Printing Starts
# number of test cases in (1,10^5)
required_input = RINT(5, POWER(10, (i // 2) + 1))
print(required_input) # Prints x into input file
for _ in range(required_input):
print(RINT(1, POWER(10, min(4, max(i // 2, 2)))))

sys.stdout.close()
# Input File Printing Ends



if __name__ == "__main__":
main()

0 comments on commit fdb3515

Please sign in to comment.