blob: 70e52fa6aaeae3c8f5edb277c2ae7cd7ed7a7feb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# Computations
## Problem 1
`automata.c`, e.g.
### Input
4
1 1 3
0 1 2
0 3 0
1 1 2
4 0011
### Output
yes
## Problem 2
`nfa.cc` takes a state table of a non-deterministic finite-state automaton, its
final states and a string from stdin and print either `yes` or `no` to stdout
to answer whether this string is recognized by the automaton, e.g.
### Input
12
0 0 0
0 0 1
0 1 3
1 0 0
1 1 1
1 1 3
2 1 0
2 1 2
3 0 0
3 0 1
3 0 2
3 1 1
2
2 3
101
### Output
yes
## Problem 3
`automata-to-grammar.c`
### Input
4
1 1 3
0 1 2
0 3 0
1 1 2
### Output
S -> $
S -> 0T
S -> 1V
T -> 0T
T -> 1U
U -> 0V
U -> 1S
V -> $
V -> 0T
V -> 1U
## Problem 4
`grammar-to-automata.cc` (C++17)
### Input
10
S -> $
S -> 0T
S -> 1V
T -> 0T
T -> 1U
U -> 0V
U -> 1S
V -> $
V -> 0T
V -> 1U
### Output
4
V T U 1
U V S 0
S T V 1
T T U 0
## Problem 5
`turing.cc` (C++17) takes a natural number `n` and `n` 5-tuples representing a
Turing machine (with `-1` being the blank), a natural number `m` and a string
of `m` binaries from stdin, then print the output string to stdout, e.g.
### Input
7
0 0 0 0 1
0 1 1 1 1
0 -1 3 -1 1
1 0 0 0 1
1 1 2 0 -1
1 -1 3 -1 1
2 1 3 0 1
6
0 1 0 1 1 0
### Output
010000
|