|
|
back to boardhints (Nostradamus advised this) 1) Start with the FOUR final states. 2) Use only 15 states. 3) If it doesn't work out, then read the hint further. unsigned char constexpr stopStates = 4; auto constexpr go = []() {//state machine (2D array) std::array<std::array<decltype(+stopStates),256>,15> g; for(auto&e : g) //default std::fill(e.begin(), e.end(), g.size());//wrong state for(size_t i = 0; i!=stopStates; ++i) //default g[i]['i'] = stopStates, g[i]['o'] = stopStates+1; //===== stop states ===== g[0]['p'] = 8; //puton //in \ out g[1]['p'] = 12; //put //input \ output g[2]['o'] = 14; //on g[2]['p'] = 8; //puton //put_on g[3]['p'] = 8; //puton g[3]['e'] = 0; //e //===== non stop states ===== g[4]['n'] = 1; // i -> in g[5]['n'] = 6; // o -> on g[5]['u'] = 7; // o -> ou g[6]['e'] = 0; // on -> one g[7]['t'] = 1; // ou -> out g[8]['u'] = 9; // p -> pu g[9]['t'] = 10; // pu -> put g[10]['o'] = 11; // put -> puto g[11]['n'] = 0; // puto -> puton g[12]['u'] = 13; // ?p -> ?pu g[13]['t'] = 2; // ?pu -> ?put g[14]['n'] = 3; // ?puto -> ?puton g[14]['u'] = 7; // ?puto -> ?putou return g; //todo: Timus - automatic construction of a MINIMAL state machine (NP ?) }(); |
|
|