Friday, 26 September 2014

Slog Wars Episode II Attack of the Crease

So today in class we did an exercise involving a piece of paper and evaluating the creases that occur from folding it. We were told to come up with two or so plans before attempting to solve it, but the problem proved to be quite challenging and both methods failed. The difficulty wasn't from finding the number of creases, but the way they arranged themselves. The one given seemed to be that the middle crease was always down, as well as the fact that either side of it was mirrored by the other.

As for the number of creases, we tried to find a set rule for that before realizing its would be much easier to explain using recursion. The following code fragment shows the way the number of creases (returned) compares to the number of folds (x)

public int crease ( int x ) {

    if ( x == 1)
        return 1;
    else
        return 2 * crease (x - 1) + 1;
}

I'm fairly certain this code is correct, but I haven't worked with Java for a while and there may be a mistake or two.  Anyway, this exercise was interesting, and while I didn't manage to completely explain the solution I found it to be good practice in analytical reasoning.

1 comment:

  1. LOL nice title haha. I honestly enjoyed this lesson. Was very interesting! Its just so cool how we can turn mathematical problems into programs!

    ReplyDelete