double measure(Tape& tape) { uint64_t result(0); timer t; t.start(); std::accumulate(tape.begin(), tape.end(), result); return t.stop(); }
inline void move_head(char move) { if (move == 'l') pos -= 1; else if (move == 'r') pos += 1; else throw string("unknown state"); if (pos < 0) { tape.insert(tape.begin(), init); pos = 0; } if (pos >= tape.size()) { tape.push_back(init); } moves++; }