## Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Author: Timo Welti // Prog: WeltiTimo2.cpp #include #include void f (const unsigned int i); void x (const unsigned int i) { if (i > 0) { ifm::forward(2); ifm::save(); ifm::left(35); ifm::forward(2); ifm::right(20); ifm::jump(); f(i-1); ifm::restore(); ifm::save(); ifm::right(35); ifm::forward(2); ifm::left(20); ifm::jump(); f(i-1); ifm::restore(); } } void f (const unsigned int i) { if (i==0) { ifm::jump(2); } else { ifm::forward(); ifm::save(); ifm::left(45); ifm::forward(); ifm::right(90); ifm::forward(); ifm::restore(); ifm::right(45); ifm::forward(); ifm::left(90); ifm::forward(); ifm::right(45); ifm::forward(); x(i-1); } } void y (const unsigned int i) { if (i > 0) { ifm::save(); ifm::left(90); x(i); f(i); ifm::restore(); ifm::save(); ifm::right(90); x(i); f(i); ifm::restore(); ifm::jump(50); } } int main () { std::cout << "Number of iterations (enter a higher number than 11, around 23) =? "; unsigned int n; std::cin >> n; ifm::save(); y(n); ifm::restore(); ifm::left(90); y(n-12); return 0; }