Compare commits
15 Commits
c04d0cf332
...
3b17708166
Author | SHA1 | Date | |
---|---|---|---|
|
3b17708166 | ||
|
cb669e1c86 | ||
|
39345a1424 | ||
|
713fa2349d | ||
|
fa7060ad43 | ||
|
f11377a4b5 | ||
|
3e4026d2db | ||
|
cfb4d0806d | ||
|
4b34cb1d3a | ||
|
60e52dd992 | ||
|
fec8352787 | ||
|
b12c09ad32 | ||
|
85c35b6bdf | ||
|
b2809dd921 | ||
|
7fde0b4513 |
@ -1,6 +1,11 @@
|
||||
|
||||
## Zajęcia 1
|
||||
|
||||
Copyright AMU Poznan
|
||||
|
||||
Made by multiple people
|
||||
|
||||
|
||||
### Informacje na temat przedmiotu
|
||||
|
||||
Prowadzący: Jacek Kałużny
|
||||
|
8
TaskB00/description.txt
Normal file
8
TaskB00/description.txt
Normal file
@ -0,0 +1,8 @@
|
||||
Read a description of a deterministic finite-state automaton in the AT&T format
|
||||
(without weights) from the file in the first argument.
|
||||
|
||||
Read strings from the standard input.
|
||||
If a string is accepted by the
|
||||
automaton, write YES, otherwise- write NO.
|
||||
|
||||
The program is invoked like this: ./run.py fsa_description.arg < test1.in > test1.out
|
16
TaskB00/fsa_description.arg
Normal file
16
TaskB00/fsa_description.arg
Normal file
@ -0,0 +1,16 @@
|
||||
0 1 x
|
||||
1 2 y
|
||||
2 3 z
|
||||
0 4 y
|
||||
0 4 z
|
||||
1 4 x
|
||||
1 4 z
|
||||
2 4 x
|
||||
2 4 y
|
||||
3 4 x
|
||||
3 4 y
|
||||
3 4 z
|
||||
4 4 x
|
||||
4 4 y
|
||||
4 4 z
|
||||
3
|
26
TaskB00/run.py
Normal file
26
TaskB00/run.py
Normal file
@ -0,0 +1,26 @@
|
||||
import sys
|
||||
|
||||
def is_accepted(fsa, input_string):
|
||||
current_state = 0
|
||||
for symbol in input_string:
|
||||
if (current_state, symbol) in fsa:
|
||||
current_state = fsa[(current_state, symbol)]
|
||||
else:
|
||||
return False
|
||||
return current_state == 4
|
||||
|
||||
fsa_file = sys.argv[1]
|
||||
fsa = {}
|
||||
with open(fsa_file, 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split('\t')
|
||||
if len(parts) == 3:
|
||||
state, next_state, symbol = parts
|
||||
fsa[(int(state), symbol)] = int(next_state)
|
||||
|
||||
for line in sys.stdin:
|
||||
input_string = line.strip()
|
||||
if is_accepted(fsa, input_string):
|
||||
print("YES")
|
||||
else:
|
||||
print("NO")
|
BIN
TaskB00/test1.exp
Normal file
BIN
TaskB00/test1.exp
Normal file
Binary file not shown.
9
TaskB00/test1.in
Normal file
9
TaskB00/test1.in
Normal file
@ -0,0 +1,9 @@
|
||||
xxyz
|
||||
xyz
|
||||
xy
|
||||
zz
|
||||
xxy
|
||||
yzx
|
||||
|
||||
x
|
||||
xyzz
|
10
TaskB01/description.txt
Normal file
10
TaskB01/description.txt
Normal file
@ -0,0 +1,10 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
||||
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.
|
||||
|
12
TaskB01/fsa_description.arg
Normal file
12
TaskB01/fsa_description.arg
Normal file
@ -0,0 +1,12 @@
|
||||
0 1 0
|
||||
0 3 1
|
||||
3 3 0
|
||||
3 3 1
|
||||
1 3 0
|
||||
1 2 1
|
||||
2 4 1
|
||||
4 4 1
|
||||
4 5 0
|
||||
5 5 0
|
||||
2 5 0
|
||||
5 2 1
|
27
TaskB01/run.py
Normal file
27
TaskB01/run.py
Normal file
@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
def is_accepted(fsa, input_string):
|
||||
current_state = 0
|
||||
for symbol in input_string:
|
||||
if (current_state, symbol) in fsa:
|
||||
current_state = fsa[(current_state, symbol)]
|
||||
else:
|
||||
return False
|
||||
return current_state == 2
|
||||
|
||||
fsa_file = sys.argv[1]
|
||||
fsa = {}
|
||||
with open(fsa_file, 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split(' ')
|
||||
if len(parts) == 3:
|
||||
state, next_state, symbol = parts
|
||||
fsa[(int(state), symbol)] = int(next_state)
|
||||
|
||||
|
||||
for line in sys.stdin:
|
||||
input_string = line.strip()
|
||||
if is_accepted(fsa, input_string):
|
||||
print("YES")
|
||||
else:
|
||||
print("NO")
|
BIN
TaskB01/test.exp
Normal file
BIN
TaskB01/test.exp
Normal file
Binary file not shown.
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
|
9
TaskB02/description.txt
Normal file
9
TaskB02/description.txt
Normal file
@ -0,0 +1,9 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
||||
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.
|
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
|
11
TaskB03/description.txt
Normal file
11
TaskB03/description.txt
Normal file
@ -0,0 +1,11 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
||||
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.
|
||||
|
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
|
11
TaskB04/description.txt
Normal file
11
TaskB04/description.txt
Normal file
@ -0,0 +1,11 @@
|
||||
Use a deterministic finite-state automaton (FSA) engine from the TaskE00.
|
||||
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.
|
||||
|
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
|
10
TaskB05/description.txt
Normal file
10
TaskB05/description.txt
Normal file
@ -0,0 +1,10 @@
|
||||
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.
|
||||
|
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
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
|
9
TaskB06/description.txt
Normal file
9
TaskB06/description.txt
Normal file
@ -0,0 +1,9 @@
|
||||
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.
|
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
|
10
TaskB07/description.txt
Normal file
10
TaskB07/description.txt
Normal file
@ -0,0 +1,10 @@
|
||||
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.
|
||||
|
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
|
10
TaskB08/description.txt
Normal file
10
TaskB08/description.txt
Normal file
@ -0,0 +1,10 @@
|
||||
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.
|
||||
|
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
|
10
TaskB09/description.txt
Normal file
10
TaskB09/description.txt
Normal file
@ -0,0 +1,10 @@
|
||||
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.
|
||||
|
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
|
Loading…
Reference in New Issue
Block a user