Labs1
This commit is contained in:
parent
4e013f082f
commit
7bed1eaa82
9
.idea/DJFZ-2023.iml
Normal file
9
.idea/DJFZ-2023.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/jpa-buddy.xml
Normal file
6
.idea/jpa-buddy.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig">
|
||||
<option name="renamerInitialized" value="true" />
|
||||
</component>
|
||||
</project>
|
9
.idea/misc.xml
Normal file
9
.idea/misc.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" project-jdk-name="Python 3.11 (PythonTest)" project-jdk-type="Python SDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/DJFZ-2023.iml" filepath="$PROJECT_DIR$/.idea/DJFZ-2023.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
50
README.md
Normal file
50
README.md
Normal file
@ -0,0 +1,50 @@
|
||||
## Zajęcia 1 16.10.2023
|
||||
|
||||
### Informacje na temat przedmiotu
|
||||
|
||||
Prowadzący: mgr inż. Bartosz Fijałkowski
|
||||
mail: bf55466@st.amu.edu.pl
|
||||
|
||||
Gdyby była potrzeba przedyskutowania czegoś to możemy zostać po zajęciach. Można też kontaktować się ze mną mailowo.
|
||||
|
||||
W celu zaliczenia przedmiotu należy zdobyć punkty za zadania na laboratoriach oraz zaliczyć kolokwium.
|
||||
Punktowane zadania będziemy wykonywać na laboratoriach oraz po nich (przed następnymi zajęciami), ich ilość determinuje ocenę.
|
||||
Oprócz tego należy zaliczyć kolokwium z wyrażeń regularnych na ostatnich zajęciach. Sam wynik kolokwium
|
||||
nie będzie wpływał na ocenę, ale bez zdanego kolowkium nie da się zaliczyć przedmiotu. Punktacja za zadania jest następująca:
|
||||
- mniej niż 30 punktów - 2
|
||||
- 30-34- 3
|
||||
- 35-39- 3.5
|
||||
- 40-44- 4
|
||||
- 45-49- 4.5
|
||||
- więcej niż 49- 5
|
||||
|
||||
#### Wysyłanie zadań
|
||||
|
||||
Proszę stworzyć prywatne repozytorium na https://git.wmi.amu.edu.pl/ o nazwie djfz-2023-sNRINDEKSU oraz dać
|
||||
prawa do odczytu użytkownikowi bfijalkowski (prowadzący przedmiot). W NRINDEKSU proszę wpisać swój nr indeksu, np. djfz-2023-s123456.
|
||||
|
||||
Następnie w swoim repozytorium proszę spullować niniejsze repozytorium: `git pull git@git.wmi.amu.edu.pl:bfijalkowski/DJFZ-2023.git`
|
||||
W ten sposób będziemy aktualizować zadania co zajęcia.
|
||||
|
||||
Proszę rozwiązać zadanie TASKX02 lub TASKX03 w zależności od numeru indeksu. W tym celu należy dodać plik `run.py`
|
||||
w odpowiednim katalogu. Za pomocą `run_reports.py` można sprawdzić ilość punktów.
|
||||
|
||||
Do repo proszę dodawać wyłącznie plik `run.py` w odpowiednim katalogu, chyba że w zadaniu jest zaznaczone inaczej.
|
||||
Proszę również nie modyfikować innych plików.
|
||||
|
||||
Wszystkie zadania należy robić w terminie zaznaczonym w `description.txt`. Po terminie będę podawał punktację za pomocą USOSa w "sprawdziany".
|
||||
|
||||
Zadania robimy do dnia poprzedzającego następne zajęcia.
|
||||
|
||||
#### Aktualizacja repozytorium
|
||||
|
||||
We własnym repozytorium:
|
||||
|
||||
`git pull git@git.wmi.amu.edu.pl:bfijalkowski/DJFZ-2023.git`
|
||||
|
||||
## Zajęcia 1 16.10.2023 Automaty deterministyczne skończone
|
||||
|
||||
B00 - zadanie wykonywane wspólnie na zajęciach
|
||||
B01-B04, B06-B09 - po jedno dla każdego
|
||||
B05 - jedno dla wszystkich
|
||||
|
@ -8,4 +8,4 @@ automaton, write YES, otherwise- write NO.
|
||||
The program is invoked like this: ./run.py fsa_description.arg < test1.in > test1.out
|
||||
|
||||
POINTS: 3
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
DEADLINE: 2023-10-29 23:59:59
|
||||
|
9
TaskB00/test1.out
Normal file
9
TaskB00/test1.out
Normal file
@ -0,0 +1,9 @@
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
13
TaskB01/description.txt
Normal file
13
TaskB01/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
||||
Create your own FSA description to check whether the string starts with "01" and ends with "01.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
The alphabet is "0", "1".
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 1/4
|
14
TaskB01/test.exp
Normal file
14
TaskB01/test.exp
Normal file
@ -0,0 +1,14 @@
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
14
TaskB01/test.in
Normal file
14
TaskB01/test.in
Normal file
@ -0,0 +1,14 @@
|
||||
01
|
||||
10
|
||||
0101
|
||||
1010
|
||||
011101
|
||||
101010
|
||||
100010
|
||||
0100001
|
||||
|
||||
00110
|
||||
0000
|
||||
10101
|
||||
0
|
||||
1
|
13
TaskB02/description.txt
Normal file
13
TaskB02/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
||||
Create your own FSA description to check whether the string starts with "10" and ends with "10.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
The alphabet is "0", "1".
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 2/4
|
14
TaskB02/test.exp
Normal file
14
TaskB02/test.exp
Normal file
@ -0,0 +1,14 @@
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
14
TaskB02/test.in
Normal file
14
TaskB02/test.in
Normal file
@ -0,0 +1,14 @@
|
||||
01
|
||||
10
|
||||
0101
|
||||
1010
|
||||
011101
|
||||
101010
|
||||
100010
|
||||
0100001
|
||||
|
||||
00110
|
||||
0000
|
||||
10101
|
||||
0
|
||||
1
|
14
TaskB03/description.txt
Normal file
14
TaskB03/description.txt
Normal file
@ -0,0 +1,14 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
||||
Create your own FSA description to check whether the string contains "0"
|
||||
even number of times.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
The alphabet is "0", "1".
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 3/4
|
14
TaskB03/test.exp
Normal file
14
TaskB03/test.exp
Normal file
@ -0,0 +1,14 @@
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
YES
|
14
TaskB03/test.in
Normal file
14
TaskB03/test.in
Normal file
@ -0,0 +1,14 @@
|
||||
01
|
||||
10
|
||||
0101
|
||||
1010
|
||||
011101
|
||||
101010
|
||||
100010
|
||||
0100001
|
||||
|
||||
00110
|
||||
0000
|
||||
10101
|
||||
0
|
||||
1
|
14
TaskB03/test.out
Normal file
14
TaskB03/test.out
Normal file
@ -0,0 +1,14 @@
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
YES
|
14
TaskB04/description.txt
Normal file
14
TaskB04/description.txt
Normal file
@ -0,0 +1,14 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
||||
Create your own FSA description to check whether the string contains "0"
|
||||
odd number of times.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
The alphabet is "0", "1".
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 0/4
|
14
TaskB04/test.exp
Normal file
14
TaskB04/test.exp
Normal file
@ -0,0 +1,14 @@
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
14
TaskB04/test.in
Normal file
14
TaskB04/test.in
Normal file
@ -0,0 +1,14 @@
|
||||
01
|
||||
10
|
||||
0101
|
||||
1010
|
||||
011101
|
||||
101010
|
||||
100010
|
||||
0100001
|
||||
|
||||
00110
|
||||
0000
|
||||
10101
|
||||
0
|
||||
1
|
12
TaskB05/description.txt
Normal file
12
TaskB05/description.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskB00.
|
||||
Create your own FSA description to check whether the line contains string '19DD', where D is a digit.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
FSA alphabet is '0123456789x'.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2020-11-07 23:59:00
|
50000
TaskB05/polish_wiki_excerpt_only_digits.exp
Normal file
50000
TaskB05/polish_wiki_excerpt_only_digits.exp
Normal file
File diff suppressed because it is too large
Load Diff
50000
TaskB05/polish_wiki_excerpt_only_digits.in
Normal file
50000
TaskB05/polish_wiki_excerpt_only_digits.in
Normal file
File diff suppressed because one or more lines are too long
50000
TaskB05/polish_wiki_excerpt_only_digits.out
Normal file
50000
TaskB05/polish_wiki_excerpt_only_digits.out
Normal file
File diff suppressed because it is too large
Load Diff
6
TaskB05/simple.exp
Normal file
6
TaskB05/simple.exp
Normal file
@ -0,0 +1,6 @@
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
YES
|
6
TaskB05/simple.in
Normal file
6
TaskB05/simple.in
Normal file
@ -0,0 +1,6 @@
|
||||
3214545443
|
||||
1910
|
||||
19
|
||||
xxx2190x
|
||||
xxx21905x
|
||||
1905x54545
|
6
TaskB05/simple.out
Normal file
6
TaskB05/simple.out
Normal file
@ -0,0 +1,6 @@
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
YES
|
13
TaskB06/description.txt
Normal file
13
TaskB06/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
||||
Create your own FSA description to check whether the word "hamlet" is in the given line.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 3
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 0/4
|
169442
TaskB06/shakespeare_ascii_lower.exp
Normal file
169442
TaskB06/shakespeare_ascii_lower.exp
Normal file
File diff suppressed because it is too large
Load Diff
169442
TaskB06/shakespeare_ascii_lower.in
Normal file
169442
TaskB06/shakespeare_ascii_lower.in
Normal file
File diff suppressed because it is too large
Load Diff
3
TaskB06/simple.exp
Normal file
3
TaskB06/simple.exp
Normal file
@ -0,0 +1,3 @@
|
||||
NO
|
||||
YES
|
||||
YES
|
3
TaskB06/simple.in
Normal file
3
TaskB06/simple.in
Normal file
@ -0,0 +1,3 @@
|
||||
haml
|
||||
hamlet
|
||||
aaahamletbbb
|
13
TaskB07/description.txt
Normal file
13
TaskB07/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
||||
Create your own FSA description to check whether the word "ophelia" is in the given line.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 3
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 1/4
|
169442
TaskB07/shakespeare_ascii_lower.exp
Normal file
169442
TaskB07/shakespeare_ascii_lower.exp
Normal file
File diff suppressed because it is too large
Load Diff
3
TaskB07/simple.exp
Normal file
3
TaskB07/simple.exp
Normal file
@ -0,0 +1,3 @@
|
||||
NO
|
||||
YES
|
||||
YES
|
3
TaskB07/simple.in
Normal file
3
TaskB07/simple.in
Normal file
@ -0,0 +1,3 @@
|
||||
oph
|
||||
ophelia
|
||||
xfdfdopheliafff
|
13
TaskB08/description.txt
Normal file
13
TaskB08/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
||||
Create your own FSA description to check whether the word "juliet" is in the given line.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 3
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 2/4
|
169442
TaskB08/shakespeare_ascii_lower.exp
Normal file
169442
TaskB08/shakespeare_ascii_lower.exp
Normal file
File diff suppressed because it is too large
Load Diff
3
TaskB08/simple.exp
Normal file
3
TaskB08/simple.exp
Normal file
@ -0,0 +1,3 @@
|
||||
NO
|
||||
YES
|
||||
YES
|
3
TaskB08/simple.in
Normal file
3
TaskB08/simple.in
Normal file
@ -0,0 +1,3 @@
|
||||
juli
|
||||
juliet
|
||||
dgfdgjulietaaa
|
13
TaskB09/description.txt
Normal file
13
TaskB09/description.txt
Normal file
@ -0,0 +1,13 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the previous task.
|
||||
Create your own FSA description to check whether the word "macbeth" is in the given line.
|
||||
Save it to fsa_description.arg file.
|
||||
|
||||
FSA alphabet is 'abcdefghijklmnopqrstuvwxyz '.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
POINTS: 3
|
||||
DEADLINE: 2020-11-07 23:59:00
|
||||
REMAINDER: 3/4
|
169442
TaskB09/shakespeare_ascii_lower.exp
Normal file
169442
TaskB09/shakespeare_ascii_lower.exp
Normal file
File diff suppressed because it is too large
Load Diff
3
TaskB09/simple.exp
Normal file
3
TaskB09/simple.exp
Normal file
@ -0,0 +1,3 @@
|
||||
NO
|
||||
YES
|
||||
YES
|
3
TaskB09/simple.in
Normal file
3
TaskB09/simple.in
Normal file
@ -0,0 +1,3 @@
|
||||
macb
|
||||
macbeth
|
||||
xadadamacbethrff
|
0
TaskB09/simple.out
Normal file
0
TaskB09/simple.out
Normal file
1
TaskX01/complex.exp
Normal file
1
TaskX01/complex.exp
Normal file
@ -0,0 +1 @@
|
||||
15
|
5
TaskX01/complex.in
Normal file
5
TaskX01/complex.in
Normal file
@ -0,0 +1,5 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
1
TaskX01/complex.out
Normal file
1
TaskX01/complex.out
Normal file
@ -0,0 +1 @@
|
||||
15
|
6
TaskX01/description.txt
Normal file
6
TaskX01/description.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Print the sum of integers read from the standard input.
|
||||
Note: this is just an example of a task (and a solution).
|
||||
The task has a solution already, do not solve it!
|
||||
|
||||
POINTS: 1
|
||||
DEADLINE: 2023-10-29 23:59:59
|
7
TaskX01/run.py
Normal file
7
TaskX01/run.py
Normal file
@ -0,0 +1,7 @@
|
||||
import sys
|
||||
|
||||
count = 0
|
||||
for line in sys.stdin:
|
||||
count += int(line)
|
||||
|
||||
print(count)
|
1
TaskX01/simple.exp
Normal file
1
TaskX01/simple.exp
Normal file
@ -0,0 +1 @@
|
||||
4
|
2
TaskX01/simple.in
Normal file
2
TaskX01/simple.in
Normal file
@ -0,0 +1,2 @@
|
||||
2
|
||||
2
|
1
TaskX01/simple.out
Normal file
1
TaskX01/simple.out
Normal file
@ -0,0 +1 @@
|
||||
4
|
5
TaskX02/description.txt
Normal file
5
TaskX02/description.txt
Normal file
@ -0,0 +1,5 @@
|
||||
Print the number lines read from the standard input.
|
||||
|
||||
POINTS: 1
|
||||
DEADLINE: 2023-10-29 23:59:59
|
||||
REMAINDER 0/2
|
1
TaskX02/simple.exp
Normal file
1
TaskX02/simple.exp
Normal file
@ -0,0 +1 @@
|
||||
3
|
3
TaskX02/simple.in
Normal file
3
TaskX02/simple.in
Normal file
@ -0,0 +1,3 @@
|
||||
raz
|
||||
dwa
|
||||
trzy
|
6
TaskX03/description.txt
Normal file
6
TaskX03/description.txt
Normal file
@ -0,0 +1,6 @@
|
||||
For each line read from the standard input print the number of characters
|
||||
(not counting the end-of-line character), a space and the line read.
|
||||
|
||||
POINTS: 1
|
||||
DEADLINE: 2023-10-29 23:59:59
|
||||
REMAINDER 1/2
|
4
TaskX03/simple.exp
Normal file
4
TaskX03/simple.exp
Normal file
@ -0,0 +1,4 @@
|
||||
9 Szeregowy
|
||||
4 Rico
|
||||
8 Kowalski
|
||||
7 Skipper
|
4
TaskX03/simple.in
Normal file
4
TaskX03/simple.in
Normal file
@ -0,0 +1,4 @@
|
||||
Szeregowy
|
||||
Rico
|
||||
Kowalski
|
||||
Skipper
|
4
TaskX03/simple.out
Normal file
4
TaskX03/simple.out
Normal file
@ -0,0 +1,4 @@
|
||||
9 Szeregowy
|
||||
4 Rico
|
||||
8 Kowalski
|
||||
7 Skipper
|
109
run_report.py
Normal file
109
run_report.py
Normal file
@ -0,0 +1,109 @@
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_tasks_sets(dir):
|
||||
return [str(a.name).replace('.in', '') for a in Path(dir).glob('*in')]
|
||||
|
||||
|
||||
def execute_task(dir):
|
||||
task_sets = get_tasks_sets(dir)
|
||||
for task_set in task_sets:
|
||||
try:
|
||||
with open(Path(dir, f'{task_set}.in')) as f_in, open(Path(dir, f'{task_set}.out'), 'w') as f_out:
|
||||
arg = [x for x in dir.iterdir() if str(x).endswith('.arg')] # arg = [x for x in dir.iterdir() if str(x).endswith(f'{task_set}.arg')]
|
||||
if str(dir).startswith('TaskH'):
|
||||
compilation_command = ['thraxcompiler', f'--input_grammar={Path(dir, "grammar.grm")}',
|
||||
f'--output_far={Path(dir, "grammar.far")}']
|
||||
process = subprocess.Popen(compilation_command, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
process.wait()
|
||||
command = ['thraxrewrite-tester', f'--far={Path(dir, "grammar.far")}', f'--rules=FinalRule']
|
||||
else:
|
||||
command = ['python3', Path(dir, 'run.py')]
|
||||
if len(arg) != 0:
|
||||
command.append(arg[0])
|
||||
process = subprocess.Popen(command,
|
||||
stdin=f_in,
|
||||
stdout=f_out,
|
||||
stderr=subprocess.DEVNULL)
|
||||
process.wait()
|
||||
f_out.flush()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def get_index():
|
||||
return int(Path.cwd().name.split('-')[-1][1:30])
|
||||
|
||||
|
||||
def is_task_set_correct(dir, task_set):
|
||||
try:
|
||||
with open(Path(dir, f'{task_set}.out')) as f_exp, open(Path(dir, f'{task_set}.exp')) as f_out:
|
||||
f_out_lines = ''.join(f_out.readlines())
|
||||
f_exp_lines = ''.join(f_exp.readlines())
|
||||
return f_out_lines == f_exp_lines
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def is_task_correct(dir):
|
||||
task_sets = get_tasks_sets(dir)
|
||||
for task_set in task_sets:
|
||||
if not is_task_set_correct(dir, task_set):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def does_task_match_index(dir, index):
|
||||
with open(Path(dir, f'description.txt')) as f_in:
|
||||
lines = f_in.readlines()
|
||||
remainder_lines = [x for x in lines if x.startswith('REMAINDER')]
|
||||
if len(remainder_lines) == 0:
|
||||
return True
|
||||
else:
|
||||
remainder, modulus = remainder_lines[0].split(' ')[-1].split('/')
|
||||
remainder = int(remainder)
|
||||
modulus = int(modulus)
|
||||
return (index % modulus) == remainder
|
||||
|
||||
|
||||
def get_tasks(index):
|
||||
all_tasks = Path('.').glob('Task*')
|
||||
return [task for task in all_tasks if does_task_match_index(task, index)]
|
||||
|
||||
|
||||
def execute_all_tasks(tasks):
|
||||
for task in tasks:
|
||||
execute_task(task)
|
||||
|
||||
|
||||
def get_task_points(dir):
|
||||
with open(Path(dir, 'description.txt')) as f_in:
|
||||
lines = f_in.readlines()
|
||||
points = int([x for x in lines if x.startswith('POINTS')][0].split(' ')[-1].rstrip())
|
||||
return points
|
||||
|
||||
|
||||
def get_report(tasks):
|
||||
report = dict()
|
||||
for task in tasks:
|
||||
if is_task_correct(task):
|
||||
report[task] = get_task_points(task)
|
||||
else:
|
||||
report[task] = 0
|
||||
return report
|
||||
|
||||
|
||||
def print_report(report):
|
||||
for k in sorted(report):
|
||||
print(f'{k}: {report[k]}')
|
||||
print('')
|
||||
print(f'SUMMARY: {sum(report.values())}')
|
||||
|
||||
|
||||
INDEX = get_index()
|
||||
tasks = get_tasks(INDEX)
|
||||
execute_all_tasks(tasks)
|
||||
report = get_report(tasks)
|
||||
print_report(report)
|
Loading…
Reference in New Issue
Block a user