2014年10月27日星期一

Week - OCTOBER 20

Last week we learn Sierpinski triangle - an interesting triangle model!                                                  

There is an example:

(require picturing-programs)
(triangle 25 "solid" "red")


(define (stack an-image)
          (above an-image (beside an-image an-image)))

(define (Sierpinski n)
     (cond [ ( zero? n ) 🔺]
               [else (stack ( Sierpinski (- n 1)))]))
-------------------------------------------
(stack (Sierpinski (- 1 1)))

•it will appears a big triangle with four small equally triangle.
That because (Sierpinski 0) is a single triangle, (stack 0) means repeated addition other three triangles (a big triangle with four small equally triangle)

2014年10月17日星期五

Friday, October 17 2014

last week, I review the first term test and conclude five  definitions from lectures.

1) Euclidean Algorithm         VS         Brute Force

Brute Force  needs more steps to get the result but Euclidean Algorithm has less steps. It is simply to get results.

2)Adds up           VS         Algebraic formula

Algebraic formula has less steps than Adds up method

3)The Collatz  sequence

Assume a number 10,
it is even so divide 2 get 5
it is odd so times 3 plus 1 get 16
it is even so get 8
it is even so get 4
...2
...1
 the final answer is 1,

but it is only a suspect.

4) Binary Search       VS         Brute Ford


Binary Search is the best choice because Brute Ford has many steps,Binary Search has less steps



3
5)Expentional growth
6)Fibonacci Sequence





2014年10月13日星期一

lists of values

From last week, we learned reverse the lists, rest of the list, range list of  integers from 1 to 20,etc.

For example:
(first (rest (reverse (rest (list 0 1 2 3 4 5))))
the answer is 4
Firstly, we get (rest 0 1 2 3 4 5 )
then, we get (5 4 3 2 1 0)
next, we get (rest 4 3 2 1 0)
Finally, we get 4

we can conclude that if the number are images it can easily know what images order and e can easily show to the everybody the first image is which one.

Also, we learns an interesting knowledge : check values parts of  expression.
eg :(check-expect (first (list 0 1 2 3 4 5 6 7 ) whether 0 or not
that exactly means:

We can let the computer be a smart teacher!!!