Wednesday, December 5, 2012

Winding Down


Project #2 is finished now. Like the first project, completing it was a fairly rewarding task. For project 1, there was only 1 button to press but for project two there were multiple commands that you could input, using both the arrow keys and the mouse buttons. Before project 1, programming keys like this seemed pretty complicated, but once project 2 came around it wasn't that difficult at all. Practice with conditions in the past few weeks really helped with the completion of project 2.

I tried to work with someone else on the second project, but it didn't work for me. Seeing someone else try and solve the problems in ways that were different from how I would approach it made things slower. We spent a while trying to solve one of the problems for the project, and while we made some progress we didn't get very far. Once I got home and tried it on my own another day, I solved the problem really quickly. Having the same problem solving style seems to be fairly important for these projects. I wonder if this is true for other programming as well.

As the SLOG is due tonight, this will be my last entry. I have really enjoyed this course a lot, and I have learned a ton as well. I enjoyed programming the most. It has helped to give me a better understanding of what "code" is and all the things that it can do. It certainly comes up a lot in my every day life, so it is great to have a more thorough understanding of it. It also helps me better understand what my friends who are studying these things actually do with their time. I'm really glad that I got the chance to take this course.

Problem Solving!

One of the few requirements for this SLOG is that we document a problem solving episode of a "algorithmic, mathematical nature". I wanted to work on the paper folding problem since I had already given it some thought after the class discussion, but I was still having a hard time with it once I tried it at home. Instead, I went on the problem solving wiki that was provided to us, and chose a new problem from there. I settled on the Paper Slicing problem.

Understanding the problem

Given: number of straight lines
Required: number of regions

In this problem you are given a number that represents a number of straight lines. These lines theoretically divide up a piece of paper into several regions. The number of regions for 1, 2, and 3 lines were provided, and are listed below:

1 line = 2 regions
2 lines= 4 regions
3 lines = 7 regions

To better understand the problem, I created diagrams:



Creating the diagram with 3 lines helped me to realize that in order to create the most regions, the most existing regions must be intersected with the new line. 

Devising a Plan

Seeing the data in the form of a chart made it seem as though addition could be used to solve the problem. Previous problems like this that I had encountered suggested that a certain value added to the number of previous regions in order to find out the number of regions in the current state.

Carrying out the Plan

Using my addition plan I figured out what needed to be added to 2 (the number or regions created by 1 line) in order to arrive at the value 4 (the number of regions created by 2 lines). Clearly 2+2 = 4. I then saw if 4+2 = the number of regions created by 3 lines, but it was one value short. Clearly, adding 2 to the previous number of regions was not the solution to this problem. 

Looking Back

Clearly my first solution was not correct, but that didn't mean that addition wasn't the solution.

Devising a Second Plan

While executing my first plan, I realized that I was only off by 1 when using the +2 technique for 3 lines. This made me wonder if the value that I needed to add should increase each time a new line is added. This meant that I would +2, followed by +3 (2+1) for 3 lines.

Carrying our the Second Plan

1 line = 2 regions
2 lines = 2+2 = 4 regions
3 lines = 4+3 =7 regions

By increasing the number of regions added by 1 for every line I was able to solve the problem for a maximum of three lines.

Looking back

I wondered if my solution would apply if I had more data to work with. Having only 3 lines only gave me 2 opportunities to try my solution with. I decided that I needed one more opportunity before I would feel confident that I has solved the problem.

Devising a Third Plan

I was able to create a diagram with the maximum number of regions created by 4 lines:
I was able to create 11 regions with 4 lines. 

Carrying out the Third Plan

Now that I had a third piece of data, I tried out my formula again to see if my previous solution still worked.

1 line = 2 regions
2 lines = 2+2= 4 regions
3 lines = 4+3= 7 regions
4 lines = 7+4= 11 regions

Looking Back

My solution still worked with the new piece of data, and I was able to conclude that my solution was accurate.