-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflip_least_significant.cpp
More file actions
43 lines (39 loc) · 1.21 KB
/
Copy pathflip_least_significant.cpp
File metadata and controls
43 lines (39 loc) · 1.21 KB
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
#include "decl_components.hpp"
#include "turing_machine.hpp"
enum class Symbol {
_,
E,
_0,
_1
};
using enum Symbol;
using enum Action;
enum class [[=Config<Symbol>{"PrependEmpty", E, _}]] FlipLeastSignificant {
PrependEmpty [[=RL<FlipLeastSignificant,
{_0, E, Right, "ShiftRight_0"},
{_1, E, Right, "ShiftRight_1"},
{E, _, Halt, "PrependEmpty"}
>]],
ShiftRight_0 [[=RL<FlipLeastSignificant,
{_0, _0, Right, "ShiftRight_0"},
{_1, _0, Right, "ShiftRight_1"},
{E, _0, Left, "ReverseScan"}
>]],
ShiftRight_1 [[=RL<FlipLeastSignificant,
{_0, _1, Right, "ShiftRight_0"},
{_1, _1, Right, "ShiftRight_1"},
{E, _1, Left, "ReverseScan"}
>]],
ReverseScan [[=RL<FlipLeastSignificant,
{_1, _0, Halt, "ReverseScan"},
{E, _, Halt, "ReverseScan"},
{_, _, Left, "ReverseScan"}
>]],
};
int main() {
// TODO: Change signature to allow for deduction of input
TuringMachine<FlipLeastSignificant> tm{};
std::println("{}", tm.execute({_1, _0, _1, _1, _0}) | std::views::transform(state_variant_to_string));
std::println("{}", tm.execute({_0, _1, _0, _1, _0}) | std::views::transform(state_variant_to_string));
std::println("{}", tm.execute({_0, _0, _0, _0, _0}) | std::views::transform(state_variant_to_string));
}