Thursday 4 April 2013

Problem Solving

As reading through the problems, Professor Heap emailed us, I chose the first one - "Penny Piles".  The problem states that there are 64 pennies in the left drawer and 0 in the right drawer.  It asks us to rearrange the pennies so that one of the drawers has 48 pennies, using the following two commands:

1. If the left drawer has an even number of pennies, you may transfer half of them to the right drawer. If the left drawer has an odd number of pennies, operation is disallowed.

2. If the right drawer has an even number of pennies, you may transfer half of them to the left drawer. If the right drawer has an odd number of pennies, operation is disallowed 

We were also given these hints: 



Hint 1: Work backwards: Imagine you have already carried out steps that give you the desired number of pennies in one drawer. What would the second-last step be (the step just before the successful step)?

Hint 2: Smaller cases: Is there any connection between the steps to get 24 in a drawer when you start with 64, and getting 12 in a drawer when you start with 32?

Hint 3: Draw a picture: Draw a tree diagram of all the possible results (amounts of pennies in each drawer). Try to be systematic. 

Understanding the Problem: 

  • There are two drawers, the left one with 64 and the right with 0.
  • Find a way so that one of the drawers has 48 pennies.
  • Use the left and right operations given along with the hints given. 

Devise a Plan:

  • To start, I will make a visual representation with the first drawer having a even number of pennies. 
Carry out the plan:

  • First, the left drawer will have 64 pennies and I will proceed with the left operation by transferring half of the pennies to the right drawer. 
  • Next, I will repeat the same operation so that the left drawer will have 16 pennies and the right drawer has 48 pennies, which is the result I was looking for. 
Looking back:

  • If a binary tree was created, it would continue until there are a odd number in both of the drawers using both of the operations. 
  • If the operation was continued, it would be a very long process and wold eventually become impossible. 
  • When looking at the hints, working backwards is a very good method using a tree as a visual process. 
  • If we started with a different number, it may have been more difficult to get the correct number of pennies in the proper drawer , but similar techniques and hints used could be used for a different starting number. 
















Slog Post #9

Our last week of CSC104! I can't believe that the semester is almost over! It has gone by so quick! This week during lecture, we learnt about privacy and property.  I found the information on privacy very useful.  It is a big issue for many teenagers, especially in todays society.  Our generation is changing very fast in the terms of technological use.  Sometimes, in our daily lives we don't realize the information we are giving away and something may have to be done in the future to protect everyone's information.   We have our second project due tomorrow and I am almost finished it.  I found this project somewhat easier than the last.  I am feeling confident about tomorrow's quiz and the upcoming exam.  I think with some studying and a neat aid sheet, I will do very well on the exam (hopefully!).  Overall, I am really glad I took this course, and am happy with the achievements I have made throughout the course. I would defiantly recommend this course to my fellow UofT students! 



Slog Post #8

This week during lecture, we talked about networks and also operators/operating systems, a continuum of the week before the test's lecture. Our last section of the Wikipedia assignment was due this week, and we also had a quiz.  During lecture, we got our second test back.  The mark on this test was a very good achievement for me, as I went up 20% from my last test.  I felt great about this!  When doing the Wikipedia assignment, I ran into several problems with the articles I had first chosen.  One of my articles would not allow me to add photos, another wouldn't allow me to edit and another did not need any further editing done to it.  So, I chose new articles and re-read the editing rules as a refresher.  I found this part of the assignment more difficult than the other two.  But after a couple hours, I finally made several changes to some articles. The quiz was on the command apply.  I felt somewhat confident on the quiz. As we are nearing the end of the course, I am still learning more and more each week and am surprised at the amount of work goes into computing.

Slog Post #7

This week, we had our second test.  I had another midterm the same day as this one, so I was feeling more stressed than usual.  I was very happy to find out we were aloud another aid sheet.  After writing the test, I feel confident that I did somewhat significantly better then the last test. The only question that I am worried about is the last question, which you had to write check-expects, explain the step-by-step process and explain the purpose of rs.  I hope we get our tests back as soon as last time!  I looked into some of my fellow classmates slog's this week to see how they were doing, and I felt at ease when others were feeling the exact same way I was about the tests, projects and lecture material. We have no quiz this week!

Slog Post #6

This week in lecture, we learnt about modern hardware architecture, operators and operating systems. I was very interested in this week's topic because my dad is always talking about hardwares and operating systems to me, and I always just brush the topic off because I never understood what he was talking about.  But after lecture and a phone call home, I was able to impress my dad with some computer knowledge!  I found it interesting that there are so many ways to store information in a computer, such as in the flash drive, compact disc or the hard drive. I was feel very confident with this weeks material!  Our first project is due this week, along with a quiz. This weeks quiz is a redo of last weeks...which makes me worried I didn't do so well on the last quiz!  I have started the project, but am not feeling too confident in it.  I am getting more and more worried as tomorrow comes and it looks like it may be a late night for me in hopes of running the two assignments successfully tonight!

Slog Post #5

So this week has been a little bit more hectic than usual in computer class! On Tuesday, we learned how to make a clock with an hour hand, a minute hand, and a second hand on DrRacket. The things that we are learning how to do on DrRacket are becoming more and more complex! We also have part 2 of our Wikipedia assignment due tomorrow. I spent quite a while going through all of the "Learn How" sections in order to familiarize myself with how to work the website. We also have our second assignment due soon, and I am finding it a little bit tricky, however I am going to spend a lot of time working on it this weekend to get it done

This week was a little more busier then most in CSC104!  On Tuesday, we learnt how to make a clock which included an hour, minute and second hand!  I found this very interesting! In the other lecture this week, we learnt more about binary numbers, and how to multiply or add them. Again, as like last week I was very confused until I went over my notes and looked up more information online. An example of multiplying and adding a binary number would be:


-add 13 & 5 together:


  1101

+0101
----------
10010

13 + 5 = 10010

-multiply 13 & 5 together :

                   1101
                 x0101
                -----------
               1000001

13 x 5 = 1000001

After learning about numbers, we went on to talk about images and sound.  I found this section very interesting, images is represented as rectangular arrays of glowing pixels where as sound is represented by using a stream of numbers.

This week, we also had our Wikipedia part II due, and also a quiz.  This part of the Wikipedia assignment, I particularly enjoyed because I always wondered what the rules were for editing articles on wikipedia and also how the community of wikipeidans communicate with each other. After finishing the assignment, I moved on to preparing for the quiz, which I found somewhat challenging.    This week, we watched the 'decompose and reconstruct' videos.  I learnt things such as how to make a colour more blue, or to swap the colour's in it. I feel confident in the quiz!




Slog Post #4

This week during lecture, we learnt about how computers have converged on two design ideas: digital and binary. We also learnt about Boolean logic (simple operators) and then on to Boolean arithmetic, writing numbers in binary and binary decimals.  During lecture, I was very confused with how to write a number in Binary, but after coming back and looking at the longer notes on these subjects, I finally understood.

For example, to write 13 in binary it would be:

1101 ... = 8 + 4 + 0 + 1 = 13

This week, we also had a quiz.  When preparing for the quiz, we were expected to watch the 'racket aggregrates' videos.  While preparing for the quiz, I learnt how to do many things in Dr. Racket.  First, we learnt about 'lists'.  For example, I learnt how to do the following on Dr.Racket:

> (range 1 11 1)
1 2 3 4 5 6 7 8 9 10 11

or

(list 1 2 3 4)
>(length menagerie)
4
>(first menagerie)
1
>(rest menagere)
2 3 4

Secondly, while preparing for the quiz, I learnt about 'struts'.  After the struts, I also learnt about using maps in Dr. Racket.  For example:

>(map sqr num-list)
(list 1 4 9 16 25 36 49 64 81 100)

Overall, this week I found the information we learnt very informative and I feel confident about this week's material.  I found this weeks quiz very straight forward, and I look forward to next week in learning more about computing!