void BruteForceFinder::Worker::search_last_corner_cycle(size_t begin, size_t end) { const Algorithm skeleton = this->solving_step.back().skeleton; static constexpr byte twist_flag = CubeTwist::corners | CubeTwist::reversed; const auto& corner_cycle_index = this->finder.corner_cycle_index; int index = -1; for (size_t insert_place = begin; insert_place <= end; ++insert_place) { if (insert_place == begin) { Cube state; state.twist(skeleton, 0, insert_place, twist_flag); state.twist(this->finder.inverse_scramble_cube, twist_flag); state.twist(skeleton, insert_place, skeleton.length(), twist_flag); index = state.corner_cycle_index(); } else { index = Cube::next_corner_cycle_index(index, skeleton[insert_place - 1]); } this->try_last_insertion(insert_place, corner_cycle_index[index]); if (skeleton.swappable(insert_place)) { int swapped_index = Cube::next_corner_cycle_index( Cube::next_corner_cycle_index(index, skeleton[insert_place]), Algorithm::inverse_twist[skeleton[insert_place - 1]] ); this->try_last_insertion(insert_place, corner_cycle_index[swapped_index], true); } } }