2013-04-05

The penny piles



The problem is:

You are sitting in front of two drawers. The left drawer contains 64 pennies, the right drawer contains nothing.
-          Q1: Can you arrange things so that one of the drawers has 48 pennies, using the following two operations?

L: If the left pile has an even number of pennies, transfer half of them to the right pile. If the left pile has an odd number of pennies, operation L is disallowed.

R: If the right pile has an even number of pennies, transfer half of them to the left pile. If the right pile has an odd number of pennies, operation R is disallowed.

-          Q2: Choose another number in the range [0,64]. Starting from the initial position, can you arrange things that one of the drawers has that number of pennies?
Are there any numbers in that range that are impossible to achieve?



Understand the Problem:
Basically it is about to get a certain number of pennies only by moving a half of pennies in the piles every time
Let us define “DL” to be “the number of pennies in the left drawer” and “DR” to be “the number of pennies in the right drawer”. And as we already know, “L” represents operation L, and “R” represents operation R.

[For Q1]

Devising a Plan:
Since there are only 64 pennies in the left drawer and nothing in the right one in the initial status, what we can do is only to apply the L operation. By this we will get
DL=32 and DR=32.
At this moment, we have equal amount of pennies in each drawer. There is no difference for us to apply operation L or R. Let’s try operation L, and then we will get
DL=16 and DR=48.
As we can see, we already get a drawer with 48 pennies.

Carry Out The Plan:


Look Back:
For these kinds of small cases, simply trying to apply operations L and R and see what happens is enough.

[For Q2]


Devising a Plan:
According to the hints3, we plan to make a tree diagram by which we can get all possibilities of numbers we can get by applying L and R operations. By following the diagram, we can
1) Pick a number in the diagram and track it (to see how we get it by L and R operations).
2) Find the numbers that are impossible to achieve.(If the number is not in this diagram, then it can’t be achieved.)


Carry Out The Plan:

To achieve target 1)
I chose a number 20 pointed by the mouse in the diagram.
By the diagram we can see that to get number 20, we need to apply the operation L first, followed by L, R, and end with L. At that time, we can get 20 pennies in the left drawer.

To achieve target 2)
Since we could find all the numbers in the range [1, 64] in this diagram, we can conclude that there is no number that can’t be achieved between the range of 0 and 64.

Look Back:
This way is kind of troublesome since we have to list the diagram. But it is a easy way to work out the problem because it has little thing about mathematics.

[For Q3]

Devising a Plan:
According to the tree diagram we can conclude that:
We take 6 operations to get an odd number
64 = 26
All the numbers in the range [1, 64] are possible to get
In conclusion, we are guessing that if we start with a different number of pennies in the left drawer, as long as that number is 2n (n=1,2,3……), every number in the range of [1, 2n] is impossible to get by L and R operations.

Carry Out The Plan:
We can start with some smaller cases.
E.g. 1If we start with 22 = 4 pennies in the left drawer, we can find that:

As we can see, we take 2 operations to get an odd number, also, all the numbers in the range [1, 4]. The guess is true.

E.g. 2) If we start with 23=8 pennies in the left drawer, we can find that:

As we can see, we take 3 operations to get an odd number, also, all the numbers in the range [1, 8]. The guess is true.

Look Back:
This way is mainly about guessing instead of proofing.By referring to the way of solving this problem on
We checked the https://wwwcgi.cdf.toronto.edu/~heap/cgi-bin/Solvent/wiki.pl?Piotr%20Bugaj which uses the way of programming. Maybe that is a better and reliable way to solve this problem.

Partner : Jiaxun Zhang

Her slog address is 
http://emily88zhang.blogspot.ca/search?updated-min=2013-01-01T00:00:00-08:00&updated-max=2014-01-01T00:00:00-08:00&max-results=9

2013-04-04

CSC 104 Slog-Week Twelve (Apr 1st – Apr 7th)


CSC 104 Slog-Week Twelve (Apr 1st – Apr 7th)
Security
Something new learned in the class:
Security
Some standard measure to reduce your exposure to either malicious or inadvertent harm to your computer's security:
Use good passwords
Be sure you know the person or corporation you are downloading software from
Be sure you know the person or corporation you are divulging identifying information to
Apply security patches to your software
Avoid opening dubious email
investigate various spam filters



Property】          
 ❀Categories of property:
Land Ownership
Land
Human bodies, body parts
Life forms
Tunes
Ideas
Traditional knowledge

Rationales for property
※Natural right to property
- Everything we mix our labour with becomes our property
※Property helps society
- Any resource that doesn't have an owner is used inefficiently. In this argument, as things become scarce (and desirable) we need to assign owners to them so that they aren't squandered, and the ownership can be passed around using the market.

Critiques
※Mixing your labour with nature assumes a large supply of commonly-owned raw materials (trees, land), and runs into difficulty as these things become scarce.
In practice we mix our labor with materials that are partly the result of other's labor. The calculation of which part of the result belongs to whom is controversial.
The result of mixing labor with nature, in Locke's example, was an instance of some product that could be used exclusively by the producer or sold to somebody else for their exclusive use. How does this notion of property extend to property where exclusive use defeats the (commercial) purpose of the property?
※Ownership may impede innovation. Imagine the consequences of important algorithms having private owners.
Critiques for ownership














Computers haven't changed the nature of intellectual property but only highlighted some of the issues since computers have made it cheaper and easier to make copies of products whose main content is intellectual rather than material.
Copyright protection of music and software has become two hotspots.
Copyright


Open-source
You may use and modify the program in any way you see fit, including selling it to someone else. The strength of open-source software is the potentially large community of developers writing software, and the speed with which bugs can be fixed and features added. For certain applications, for example http web servers; the open-source version is also the leading version. In some other applications (many desktop environments) proprietary software dominates.


Challenges I met this week
I encountered some problems when doing the project 2.
Contrast
When writing the check-expect function, I wrote a general function which is the same as the definition before but soon I found that I should write by the specific number. For example, by assuming make-color 56 225 225 225
When I just made a random color by pick a random number for make-color function, I cannot always get an integer by running the “sharpen-r”, which became a bug. So I looked it up on the internet about how to get an integer: it should be (quotient n1 n2) instead what I wrote: (/ n1 n2)


Fractal
Everything went on well, until I clicked the “run” button to run the program, the bug appeared. The “down” and “left” button didn’t work.
The function I wrote was:
(define (key-press rp k)
  (cond
    ; !!! write four more [question answer] pairs for this condition!
    [(equal? k "up") (make-param (+ 1 (param-depth rp)) (param-base rp))]
    [(equal? k "down") (make-param (- 1 (param-depth rp)) (param-base rp))]
    [(equal? k "right") (make-param (param-depth rp) (+ 1 (param-base rp)))]
    [(equal? k "left") (make-param (param-depth rp) (- 1 (param-base rp)))]
[else rp]))
And then I went to the office hour in CSC Help Centre and I found that it did not go well was because I transposed “(param-depth rp)” and “1” in the “donw” and “left” function. Since at that time, (param-depth rp) is already bigger than 1.
So the right function should be:
(define (key-press rp k)
  (cond
    ; !!! write four more [question answer] pairs for this condition!
    [(equal? k "up") (make-param (+ 1 (param-depth rp)) (param-base rp))]
    [(equal? k "down") (make-param (- (param-depth rp) 1) (param-base rp))]
    [(equal? k "right") (make-param (param-depth rp) (+ 1 (param-base rp)))]
    [(equal? k "left") (make-param (param-depth rp) (- (param-base rp) 1))]
    [else rp]))
This one goes well.

The test/quiz/assignment
We had a quiz this week and it was mainly about map a list and then apply a function to it. It was kind of tricky but when you totally understand how the "map" work, everything becomes easier. 
Also, the slog and project two are due this week! It is kind of tricky but I KNOW I CAN FIND THE ANSWER!


Feedback for the orther’s slogs
I read 's blog about the problem solving about The Diagonal Problem. It was a really awesome plan! The blogger did a really good job in solving the problem and also concluding it into a plan. So I left a comment "That's a really awesome one!"  =D