And here is the result of running the code in the Python Shell:
Saturday, September 27, 2014
Third Week: More on the Folding Problem (Coding)
So, now that we know the pattern, we can use recursion in Python to get the results. Below is the code that can be used to generate that pattern, given the number of folds:
And here is the result of running the code in the Python Shell:
And here is the result of running the code in the Python Shell:
Third Week: Answers to the Exciting Folding Problem
This class has probably been my most favorite class of all, probably because I am such a big fan of logic problems. And although the folding problem seemed pretty challenging at first, after giving it a little thought and using observation, I was able to find the pattern very quickly, before the hints were given. So below are the answers to this problem explained thoroughly, I hope.
Obviously the first step was to test the first few cases, for which I got the following results ('D' is down crest, 'U' is the up crest):
Fold #1 = D
Fold #2 = U D D
Fold #3 = U U D D U D D
The first major observation that helped me crack the problem was to notice that the middle element is always 'D'. Then, it was just a matter of identifying what comes after that 'D' and before that middle 'D'. To get the answer, we have to realign the answers to the right, with the middle D underlined:
Fold #1 = D
Fold #2 = U D D
Fold #3 = U U D D U D D
Fold #4 = U U D U U D D D U U D D U D D
Do you see it now? The pattern on the right of the middle 'D' is the pattern of the previous fold. Now, it's just the matter of identifying what is the pattern on the left of the middle 'D'. But if you look at the first patterns (aligned center), and compare the results, you'll see that they are symmetrical in a way. If you switch every 'U' for 'D', and 'D' for 'U' on the left side, you'll see the symmetry:
Fold #2 = U D D = D D D
Fold #3 = U U D D U D D = D D U D U D D
Therefore, the left pattern is the reverse of the opposite values of the right pattern. Mathematically, I guess you can represent the answer the following way:
New-Pattern = reverse (not Old-Pattern) + 'D' + Old-Pattern
Geometrically, we can also see a pattern, as shown below: in the red we see the previous pattern repeated, and in the dashed green we see the old pattern again, only rotated by 90 degrees.
Obviously the first step was to test the first few cases, for which I got the following results ('D' is down crest, 'U' is the up crest):
Fold #1 = D
Fold #2 = U D D
Fold #3 = U U D D U D D
The first major observation that helped me crack the problem was to notice that the middle element is always 'D'. Then, it was just a matter of identifying what comes after that 'D' and before that middle 'D'. To get the answer, we have to realign the answers to the right, with the middle D underlined:
Fold #1 = D
Fold #2 = U D D
Fold #3 = U U D D U D D
Fold #4 = U U D U U D D D U U D D U D D
Do you see it now? The pattern on the right of the middle 'D' is the pattern of the previous fold. Now, it's just the matter of identifying what is the pattern on the left of the middle 'D'. But if you look at the first patterns (aligned center), and compare the results, you'll see that they are symmetrical in a way. If you switch every 'U' for 'D', and 'D' for 'U' on the left side, you'll see the symmetry:
Fold #2 = U D D = D D D
Fold #3 = U U D D U D D = D D U D U D D
Therefore, the left pattern is the reverse of the opposite values of the right pattern. Mathematically, I guess you can represent the answer the following way:
New-Pattern = reverse (not Old-Pattern) + 'D' + Old-Pattern
Geometrically, we can also see a pattern, as shown below: in the red we see the previous pattern repeated, and in the dashed green we see the old pattern again, only rotated by 90 degrees.
Tuesday, September 16, 2014
First and Second Week (September 8 - 19)
These weeks were my first two weeks of CSC165H1, or of any course, for that matter. And while I was a little stressed out about lectures, especially given the fact that I missed a couple of lectures as I was wait-listed on ROSI, I found it very easy and stress-free to adapt. I guess I have to give a lot of credit to my instructor, Danny Heap, for making the lectures so exciting. He is always upbeat and makes the class very enjoyable. What I also like about his method of teaching is that he always explains every topic very thoroughly and provides a lot of examples to help understand and remember that topic. As well, every question that I - or any of my fellow classmates - have are immediately taken up and answered with absolute clarity.
So far, I am extremely satisfied with the course. It covers material similar to some other courses I am also taking (MAT137Y1), but it provides more in-depth definitions and relates it to computer programming. As well, this course is also acting as a refresher of Python syntax, which I haven't used for some time.
The one problem that I really enjoyed solving this week was figuring out the ages of the 3 kids given the facts that the ages multiply to give 36, their sum is not unique, and that the eldest person plays piano. It didn't take me long to figure out the two possibilities (9, 2, 2 or 6, 6, 1) that might meet the first two conditions, so the answer - 9, 2, 2 - was pretty obvious. I liked this example because it involved logical thinking to get to the answer. Besides, it was also cool to use the new notation to outline the problem first, making sure to indicate all the given and required variables, and then coming up with multiple methods to find the solution.
As well, a lot of attention was paid to quantifiers, implications, converse, and negation throughout the lectures. And while for some people it may be easier to use mental Venn diagrams, I also found it more helpful to reword the question first, and then see how to prove it wrong (when using negation). For example, take question 1 d) from tutorial exercise #1, "some of the three python programs don't pass all three test suites." To negate this sentence, I first change it to "not all programs pass all three test suites", and then just get rid of the "not", thus getting the following negating sentence - "all programs pass all three tests." EDIT: As I learned today, this technique is actually called 'contrapositive,' and not 'negation,' but the idea is the same - it toggles the truth value of the statement.
Overall, I am very happy with my experience with CSC165H1 so far, and I am looking forward to my future lectures!
So far, I am extremely satisfied with the course. It covers material similar to some other courses I am also taking (MAT137Y1), but it provides more in-depth definitions and relates it to computer programming. As well, this course is also acting as a refresher of Python syntax, which I haven't used for some time.
The one problem that I really enjoyed solving this week was figuring out the ages of the 3 kids given the facts that the ages multiply to give 36, their sum is not unique, and that the eldest person plays piano. It didn't take me long to figure out the two possibilities (9, 2, 2 or 6, 6, 1) that might meet the first two conditions, so the answer - 9, 2, 2 - was pretty obvious. I liked this example because it involved logical thinking to get to the answer. Besides, it was also cool to use the new notation to outline the problem first, making sure to indicate all the given and required variables, and then coming up with multiple methods to find the solution.
As well, a lot of attention was paid to quantifiers, implications, converse, and negation throughout the lectures. And while for some people it may be easier to use mental Venn diagrams, I also found it more helpful to reword the question first, and then see how to prove it wrong (when using negation). For example, take question 1 d) from tutorial exercise #1, "some of the three python programs don't pass all three test suites." To negate this sentence, I first change it to "not all programs pass all three test suites", and then just get rid of the "not", thus getting the following negating sentence - "all programs pass all three tests." EDIT: As I learned today, this technique is actually called 'contrapositive,' and not 'negation,' but the idea is the same - it toggles the truth value of the statement.
Overall, I am very happy with my experience with CSC165H1 so far, and I am looking forward to my future lectures!
Subscribe to:
Posts (Atom)


