2012年12月5日星期三

A paper folding problem!

I was curious about the question about paper folding disscussed in the lecturea and I was still confused about the question why can't a paper be fold more than 7 times.  why why why?????
Therefore, I searched on Internet for the solution.

The soultion: If you have a normal sheet of notebook paper and you try to fold it in half multiple times, you probably cannot get it to fold more than 6 times. Maybe 7 if you are really strong. That maximum limit is caused by two things:
1) The number of layers of paper doubles with each fold. So you start with a single layer, then you have two layers, then four, then eight, then 16, then 32, then 64 layers after six folds. Maybe if you are very strong, and you use a pair of pliers, you can get to seven folds and 128 layers, but it probably won’t be pretty.
2) At that point the sheet of paper is so small, and the number of layers so large relative to the small size, and the distortion caused by the folds so great, that there is no way to fold it again. You can’t apply enough leverage, and the fibers of the paper do not have enough flexibility for another fold.



There is a link to a video on YouTube prove this explanation.
http://www.youtube.com/watch?v=kRAEBbotuIE&feature=player_embedded

Just a brief summary to the solution of Exercise 8.4.1

I found Exercise 8.4.1 is a little bit hard for me to follow the steps, therefore, I summarize it for remembering and undertansing more easily.
1. I need a handler, a key handler, a draw handler(since a non-image model)
2.A model is a number indicating the x-coordinate of the picture.
3. ; handle-draw : model->image (draw handlers)
    ; handle-draw : model->image
key handlers: ; handle-key :model key->model
mouse handlers: ; handle-mouse :model number(mouse-x)
                                                 event->model
4.Write the draw handler: calendar-at-x
5.Write the mouse handler:
; add1-on-mouse : number(x)
; number(mouse-x) number(mouse-y)
; event -> number
(check-expect (add1-on-mouse 3 29 348 "blarg") 4)
(check-expect (add1-on-mouse 15 503 6 "glink") 16)
(define (add1-on-mouse x mouse-x mouse-y event) (+ x 1) or (add1 x)
; x number
; mouse-x number (ignore)
; mouse-y number (ignore)
; event whatever (ignore)
6.Write the key handler:
; sub4-on-key : number (x) key -> number
(check-expect (sub4-on-key 7 "dummy argument") 3)
(check-expect (sub4-on-key 4 "whatever") 0)
(define (sub4-on-key x key) (- x 4))
; x number
; key whatever (ignore)
7.Initial model: Let’s start halfway across the window, at an x coordinate of 250.
8.Call big-bang: (big-bang 250 (check-with number?) (on-draw calendar-at-x)
                                                              (on-mouse add1-on-mouse) (on-key sub4-on-key))

I am done!

Two probelms solved in Chapter 8 of the book

I found difficulties in solving Exercise 8.3.4 and 8.3.5 and I asked for help. Here is my feedback:
Exercises 8.3.4: Develop an animation of a square, initially 1x1,which grows by 1 pixel in each dimension at each clock tick,centered in a 200x200 window.
Soultion:
(check-expect (growing-square 5)(overlay (rectangle 5 5 "solid" "red")
                                                    (rectangle 200 200 "solid" "white")))
(define (growing-square x)(overlay (rectangle x x "solid" "red")
                                                     (rectangle 200 200 "solid" "white")))
; (big-bang 1 (check-with number ?)(on-draw growing-square)
                                                       (on-tick add 1 1))


Exercise 8.3.5: Develop an animation of a rectangle, initially 2x1, which grows by 1 pixel in height and 2 in width at each clock tick, centered in a 200x200 window.
Solution:
(check-expect (growing-rectangle 5)(overlay (rectangle(* 5 2) 5 "solid" "red")
                                                    (rectangle 200 200 "solid" "white")))
(define (growing-rectangle x)(overlay (rectangle (* x 2) x "solid" "red")
                                                     (rectangle 200 200 "solid" "white")))
; (big-bang 1 (check-with number ?)(on-draw growing-rectangle)
                                                       (on-tick add 1 1/2))

An algorithm used in my life

I make a sandwich for my breakfast in the kitchen, as follows:
1.Find several pieces of bread and lettuce in the refrigerator on the west side of the kitchen, otherwise return to step 1 tomorrow.
2.Find the egg in the cupboard on the south side of the kitchen,otherwise return to step 1 tomorrow.
3.Find the frying pan on the stove on the north side of the kitchen,otherwise return to step 1 tomorrow.
4.Find the bottle of oil in the cupboard on the east side of the kitchen,otherwise return to step 1 tomorrow.
5.Pour oil into the frying pan on the stove with the proportion of 1/3 of the pan.
6.Turn the burner knob counter-clockwise  as far as it will go. If the burner doesn't light, turn the knob clockwise as far as it will go and return to step 1 tomorrow.
7.When the oil becomes hotter, strike the egg and put it on the frying pan.
8.3 minutes later, the egg becomes over-hard, and then turn the knob clockwise as far as it will go,otherwise return to step 1 tomorrow.
9.Add lettuce and the over-head into bread and then eat it!

2012年12月2日星期日

Feedback for Project2

  Last Friday, we finished project 2. Fortunately, my classmate was so friendly that he helped me with

some difficult problems.

  For instance, I was so confused about a question like: write 2 check-expect expressions for mouse-

event corresponding to button-up and button-down events. He told me "e" is the button and when "e"

is button-down, making x multiply by 20 (denmo=20) and then divide 130 (image width p1=30). If

"e" is button-up, the result is "n". I am so appreciate that he helped me. Thanks a lot!

2012年11月25日星期日

Learning from the Wikipedia

  Last Friday, we finished the third part of Wikipedia modification. The section "Learn How" helps me a lot. I 

chose to check and add reference to Wikipedia. From the section, I knew that for all quotations and

materials whose verfiability are likely to be challenged must include an citation of a source that directly 

supports the material. In addition, the most important spirit of Wikipedia is that the source must be reliable.

  According to the teaching steps, I edited the page which I thought should be modified further. Then I added 

information of the sourse website such as URL, publishers' name, accessdate and so on. Finally, I saved the 

edited page. Work has been finished. 

2012年11月13日星期二

The second term test also the last test - -b

  Unfortunatley, tomorrow is my second term test. I feel nervous again! I have no idea with the extra

notes about computer science. There are a lot of reading...

  I have a sort of premonition. This test must be harder than the first one. It cludes a lot of "bigbang"

theory. What made me happy was I did the first project with my friends last Friday~ They are good at

computer science, at least better than me ^ ^. I believe I may get a beautiful mark~haha...

  Wish me good luck tomorrow!