Tasks B04-B06

This commit is contained in:
IgnBys 2023-11-08 20:54:47 +01:00
parent 277d53a17b
commit 9c1cc64427
18 changed files with 50509 additions and 0 deletions

View File

@ -0,0 +1,4 @@
0 1 0
1 1 1
1 0 0
0 0 1

34
TaskB04/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
# used_table = 'fsa_description.arg'
# input_file = 'test.in'
# output_file = 'test.out'
used_table = sys.argv[1]
input_file = sys.argv[2]
output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='1':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

14
TaskB04/test.out Normal file
View File

@ -0,0 +1,14 @@
YES
YES
NO
NO
NO
YES
NO
YES
NO
YES
NO
NO
YES
NO

View File

@ -0,0 +1,4 @@
If you use windows please write this command in terminal:
python .\run.py .\fsa_description.arg .\test.in .\test.out
or
python .\run.py .\fsa_description.arg .\polish_wiki_excerpt_only_digits.in .\polish_wiki_excerpt_only_digits.out

View File

@ -0,0 +1,55 @@
0 1 1
0 0 2
0 0 0
0 0 3
0 0 4
0 0 5
0 0 6
0 0 7
0 0 8
0 0 9
0 0 x
1 1 0
1 1 1
1 2 9
1 0 2
1 0 3
1 0 4
1 0 5
1 0 6
1 0 7
1 0 8
1 0 x
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
2 3 7
2 3 8
2 3 9
2 3 0
2 0 x
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 0 x
4 4 0
4 4 1
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
4 4 x

File diff suppressed because it is too large Load Diff

34
TaskB05/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
# used_table = 'fsa_description.arg'
# input_file = 'test.in'
# output_file = 'test.out'
used_table = sys.argv[1]
input_file = sys.argv[2]
output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='4':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

6
TaskB05/simple.out Normal file
View File

@ -0,0 +1,6 @@
NO
YES
NO
NO
YES
YES

189
TaskB06/fsa_description.arg Normal file
View File

@ -0,0 +1,189 @@
0 1 h
1 2 a
2 3 m
3 4 l
4 5 e
5 6 t
0 0 a
0 0 b
0 0 c
0 0 d
0 0 e
0 0 f
0 0 g
0 0 i
0 0 j
0 0 k
0 0 l
0 0 m
0 0 n
0 0 o
0 0 p
0 0 q
0 0 r
0 0 s
0 0 t
0 0 u
0 0 v
0 0 w
0 0 x
0 0 y
0 0 z
0 0
1 0
1 0 h
1 0 b
1 0 c
1 0 d
1 0 e
1 0 f
1 0 g
1 0 i
1 0 j
1 0 k
1 0 l
1 0 m
1 0 n
1 0 o
1 0 p
1 0 q
1 0 r
1 0 s
1 0 t
1 0 u
1 0 v
1 0 w
1 0 x
1 0 y
1 0 z
2 0
2 0 a
2 0 b
2 0 c
2 0 d
2 0 e
2 0 f
2 0 g
2 0 i
2 0 j
2 0 k
2 0 l
2 0 h
2 0 n
2 0 o
2 0 p
2 0 q
2 0 r
2 0 s
2 0 t
2 0 u
2 0 v
2 0 w
2 0 x
2 0 y
2 0 z
3 0 m
3 0 a
3 0 b
3 0 c
3 0 d
3 0 e
3 0 f
3 0 g
3 0 i
3 0 j
3 0 k
3 0
3 0 h
3 0 n
3 0 o
3 0 p
3 0 q
3 0 r
3 0 s
3 0 t
3 0 u
3 0 v
3 0 w
3 0 x
3 0 y
3 0 z
4 0 m
4 0 a
4 0 b
4 0 c
4 0 d
4 0
4 0 f
4 0 g
4 0 i
4 0 j
4 0 k
4 0 l
4 0 h
4 0 n
4 0 o
4 0 p
4 0 q
4 0 r
4 0 s
4 0 t
4 0 u
4 0 v
4 0 w
4 0 x
4 0 y
4 0 z
5 0 m
5 0 a
5 0 b
5 0 c
5 0 d
5 0 e
5 0 f
5 0 g
5 0 i
5 0 j
5 0 k
5 0 l
5 0 h
5 0 n
5 0 o
5 0 p
5 0 q
5 0 r
5 0 s
5 0
5 0 u
5 0 v
5 0 w
5 0 x
5 0 y
5 0 z
6 6 m
6 6 a
6 6 b
6 6 c
6 6 d
6 6 e
6 6 f
6 6 g
6 6 i
6 6 j
6 6 k
6 6 l
6 6 h
6 6 n
6 6 o
6 6 p
6 6 q
6 6 r
6 6 s
6 6 t
6 6 u
6 6 v
6 6 w
6 6 x
6 6 y
6 6 z
6 6

37
TaskB06/run.py Normal file
View File

@ -0,0 +1,37 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
length = len(line)
if length == 2:
line.append(' ')
if position == line[0] and character == line[2]:
return True,line[1]
used_table = 'fsa_description.arg'
input_file = 'simple.in'
output_file = 'simple.out'
# used_table = sys.argv[1]
# input_file = sys.argv[2]
# output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='6':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

3
TaskB06/simple.out Normal file
View File

@ -0,0 +1,3 @@
YES
YES
YES

27
TaskB06/tekst.txt Normal file
View File

@ -0,0 +1,27 @@
6 6 m
6 6 a
6 6 b
6 6 c
6 6 d
6 6 e
6 6 f
6 6 g
6 6 i
6 6 j
6 6 k
6 6 l
6 6 h
6 6 n
6 6 o
6 6 p
6 6 q
6 6 r
6 6 s
6 6 t
6 6 u
6 6 v
6 6 w
6 6 x
6 6 y
6 6 z
6 6

View File

34
TaskB07/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
# used_table = 'fsa_description.arg'
# input_file = 'test.in'
# output_file = 'test.out'
used_table = sys.argv[1]
input_file = sys.argv[2]
output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='7':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

View File

34
TaskB08/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
# used_table = 'fsa_description.arg'
# input_file = 'test.in'
# output_file = 'test.out'
used_table = sys.argv[1]
input_file = sys.argv[2]
output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='6':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

View File

34
TaskB09/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
# used_table = 'fsa_description.arg'
# input_file = 'test.in'
# output_file = 'test.out'
used_table = sys.argv[1]
input_file = sys.argv[2]
output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '7'
for character in row_input_file:
if character =='\n':
if position=='0':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position