Skip to content

Commit

Permalink
Merge pull request #18 from RighterTheOriginal/main
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
RighterTheOriginal authored Sep 5, 2024
2 parents 7af3523 + 36220dc commit a239d76
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 22 deletions.
Binary file modified src/a.out
Binary file not shown.
4 changes: 2 additions & 2 deletions src/generator_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
void solve(){
'''

end_cpp_single = '''
end_cpp_single = '''
}
int main(){
Expand All @@ -15,7 +15,7 @@
solve();
}'''

end_cpp_t = '''
end_cpp_t = '''
}
int main(){
Expand Down
6 changes: 3 additions & 3 deletions src/generator_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def cin():
def solve():
'''

end_py_single = '''
end_py_single = '''
solve()
'''

end_py_t = '''
end_py_t = '''
for tc in range(int(input())):
Expand Down Expand Up @@ -53,7 +53,7 @@ def input_var_py(encoding):
indexing = ''
for i in range(c):
indexing += '[' + chr(ord('i') + i) + ']'
inp += " " + encoding.name + indexing + " = " + encoding.datatype_py[:ind] + "(cin())" + "\n"
inp += " " + encoding.name + indexing + " = " + encoding.datatype_py[:ind] + "(cin())\n"
return inp


Expand Down
24 changes: 22 additions & 2 deletions src/problem_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def __init__(self, iterations, *enclosed):
"ten": 10}


def ignore(line):
if "number of test cases" in line:
return True
if "sum" in line and "across all test cases" in line:
return True
if "sum" in line and "over all test cases" in line:
return True
if "if" in line and "then" in line:
return True
return False


# Function to check a line of input for the presence of an array
def check_array(line):
if re.search("_", line) is None:
Expand Down Expand Up @@ -108,7 +120,7 @@ def check_matrix(line):
result = line.split("lines")
num1 = result[0].split()[-1][1:-1]
return_val = check_array(result[1])
num2 = return_val.datatype[4:-1]
num2 = return_val.datatype_cpp[4:-1]
arr = return_val.name
return Variable("int[{}][{}]".format(num1,num2), "int[{}][{}]".format(num1,num2), arr)
else:
Expand Down Expand Up @@ -185,7 +197,12 @@ def check_integer(line):
return Variable("int", "int", name)


all_fxns = (check_array, check_integer, check_str, check_matrix,)
# IMPORTANT : Priority order is decided here
all_fxns = (check_matrix,
check_array,
check_str,
check_integer,
)


# Function to make all the necessary checks
Expand All @@ -194,12 +211,15 @@ def check_all(para):
lines = para.split('\n')
all_data = []
for line in lines:
if ignore(line):
continue
for check in all_fxns:
op = check(line)
if op is not None:
try:
all_data.extend(op)
except TypeError:
all_data.append(op)
print(check)
break
return all_data
20 changes: 15 additions & 5 deletions src/temp/input.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
5
1 2
1 5
2 2
10 20
1 1000000000
1
1
0
5
1 2 4 5 3
10101
5
5 4 1 3 2
10011
6
3 5 6 1 2 4
010000
6
1 2 3 4 5 6
100110
20 changes: 15 additions & 5 deletions src/temp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
using namespace std;

void solve(){
int l;
cin >> l;
int r;
cin >> r;

int n;
cin >> n;
int separated[][n];
for (int i = 0; i < ; i++){
for (int j = 0; j < n; j++){
cin >> separated[i][j];
}
}
int separated[n][n-1];
for (int i = 0; i < n; i++){
for (int j = 0; j < n-1; j++){
cin >> separated[i][j];
}
}

}

int main(){
Expand Down
13 changes: 10 additions & 3 deletions src/temp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ def cin():


def solve():
l = int(cin())
r = int(cin())

n = int(cin())
separated = [[None for j in range(n)] for i in range()]
for i in range():
for j in range(n):
separated[i][j] = int(cin())
separated = [[None for j in range(n-1)] for i in range(n)]
for i in range(n):
for j in range(n-1):
separated[i][j] = int(cin())



for tc in range(int(input())):
Expand Down
23 changes: 21 additions & 2 deletions src/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,28 @@ def test_gen_pair_integers():
#p = Problem("2008", "A")
#inp = '''The only line of each test case contains two integers $a$ and $b$ ($0 \\le a, b \\le 10^9$) — the number of '1's and the number of '2's in the array.'''
#p = Problem("2008", "C")
inp = '''The only line of each test case contains two integers $l$ and $r$ ($1 \\le l, r \\le 10^9$).
#inp = '''The only line of each test case contains two integers $l$ and $r$ ($1 \\le l, r \\le 10^9$).'''
p = Problem("2008", "D")
inp = '''The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) — the number of test cases.
The first line of each test case contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of elements in the array.
The second line of each test case contains $n$ integers $p_1, p_2, ..., p_n$ ($1 \\le p_i \\le n$) — the elements of the permutation.
The third line of each test case contains a string $s$ of length $n$, consisting of '0' and '1'. If $s_i = 0$, then the number $p_i$ is colored black; if $s_i = 1%, then the number $p_i$ is colored white.
It is guaranteed that the sum of $n$ across all test cases does not exceed %2 \\cdot 10^5$.'''
#p = Problem("2002", "G")
#inp = '''Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 100$). The description of the test cases follows.

#The first line of each test case contains a single integer $n$ ($2 \\le n \\le 20$) — the number of rows and columns.

#Each of the next $n - 1$ lines contains $n$ integers separated by single spaces — the matrix $d$ ($0 \\le d_{x, y} \\le 2n - 2$).

#Each of the next $n$ lines contains $n-1$ integers separated by single spaces — the matrix $r$ ($0 \\le r_{x, y} \\le 2n - 2$).

#It is guaranteed that the sum of all $n^3$ does not exceed $8000$.'''

'''
#code_str = full_code_cpp(check_all(p.input))
code_str_py = full_code_py(check_all(inp))
code_str_cpp = full_code_cpp(check_all(inp))
Expand Down

0 comments on commit a239d76

Please sign in to comment.