Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// IFMP Serie 9 Aufgabe Challenge // Programme: polyflake.cpp draws a "flake", you can choose the start // regular polygon and the one you'll draw on every side (works "regularly" // only for integer internal angles smaller than 180) // Recommended values: 10, 10, 4 (decagon mandala) // Author: Nicola Nesa, Gruppe I #include #include // side >= 2 // POST: the word w_i^F is drawn void f (const unsigned int i, const unsigned side) { if (i == 0) ifm::forward(); else { f(i-1, side); ifm::left((side-2)*180/side); f(i-1, side); for (unsigned int k=1; k<=(side-2); ++k) { ifm::right(180-(side-2)*180/side); f(i-1, side); } ifm::left((side-2)*180/side); f(i-1, side); } } int main () { std::cout << "Number of sides of start regular polygon =? "; unsigned int start; std::cin >> start; std::cout << "Number of sides of the side regular polygon =? "; unsigned int side; std::cin >> side; std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; for (unsigned int k=1; k<=start; ++k) { f(n, side); ifm::left(180-(start-2)*180/start); } return 0; } // for values 1, 3, >=5 : SMO symbol // for values 6 (or else), 3, >=5 : snowflake like snowflake.cpp (but starting from an // hexagon and not from a triangle, going inwards and not outwards) // for values 3, 3, >=5 : particular case of a snowflake // for values 2, 5, >=5 : teddybear // for values >=5, 4, >=5 : crossed star // for values 4, 5, >=5 : square with arrows // for values 10, 10, >=4 : mandala // ... // QUESTION: WHAT DOES THE IMAGE TEND TO, FOR START, SIDE, N TENDING TO INFINITE? // POSSIBLE ANSWER: A DARK CIRCLE? (WITH A HOLE IN THE MIDDLE?) // QUESTION: WHAT DOES THE IMAGE TEND TO, FOR (START OR SIDE) AND N TENDING TO INFINITE // AND THE OTHER ONE FIXED? // ANNOTATION: THIS PROGRAMME ALWAYS CONVERGES, BUT OTHER ONES SEEM NOT TO: THEY // HAVE VERY DIFFERENT OUTPUTS DEPENDING ON THE NUMBER OF ITERATIONS (see teddybear.cpp)