Sunday, November 25, 2012

Almost there!



I completed tutorial 9 exercises today. I had a little bit of trouble fixing the definition for spiral when I started yesterday. But I came back to it today and I was just overcomplicating the definition, trying to include more than I needed to. For make-palindrome I used the Help Desk to look up something in place of equal? since Dr. Racket should return the string as is for strings of length 0 (empty) and 1. I tried
                (>= 1 (string-length s)
and all of the check-expects passed.

I got stuck on fixing writing the check-expects for interpolate-image in Project 2. I looked up local in the Help Desk to help me understand what the function was supposed to do. I still couldn't figure it out so I left it for a few more days. I tried it again on Wednesday after class and I got both check-expects to pass. Turns out I was just trying to overcomplicate it again. Project 2 was shorter and seemed simpler to me than the first project.

I've been thinking about what algorithm to write up. I've decided to write an approach for a simple algorithm: finding the greatest number in a list of numbers. I looked over and used the approach suggested by Polya that includes 4 steps to solve a problem:

1. Understand the problem.
                What is the unknown? Which number is the largest and its value.
                What are the data? A list of numbers.
2. Devise a plan.
               
Find the connection between the data and the unknown. The unknown is a number from the   list.
                Plan: start at the beginning and go one at time through the list.
3. Carry out the plan.
4. Look Back
               
Examine the solution obtained. 

So here is my set of written instructions:

1. Look at the 1st number, assume it is the greatest in the list and call it so.
                If there is only 1 number in the list then you are done.
                If the list is greater than 1 number, go to step 2.
2. Look at the next  number in the list and identify if it is greater than the "greatest" number?
                If yes, replace it as the greatest number, and repeat step 2 until the end of the list is reached.
                If not, keep the "greatest" number as is, and repeat step 2 until you reach the end of the list.

I really enjoy working on the exercises and projects for this class because I look at them like puzzles that need solving and I like using numbers without complicated calculations. And now I am happy because I have finished everything I set out to do today.

Sunday, November 18, 2012

Too many exercises?

Last Wednesday we wrote term test #2. I found it to be completely fair, although I think I learned a lot more material than was covered on the test. I enjoy answering the Dr. Racket questions because, at least for myself, if I've done the tutorial exercises as they're given and review them quick before the test then they're straightforward to answer. You either know how Dr. Racket reads the code or you don't.

I ran through tutorial 8 this afternoon. Without specific questions or exercises I'm not sure if I spent enough time on it. I looked up apply in the Help Desk and I went through the stepper for harvest, flatten and depth. I tried defining my own leaves and trees and harvested them. I also made my own list and flattened it.

Yesterday I spent the afternoon working on Part 3 of the Wikipedia assignment. I copy edited one page, and added citations to another. Work on both pages took longer than I expected, and I spent around 3 1/2 hours on the two pages. I also found that I had to go back and reread the Learn How on Wikipedia for both edits. The first time I clicked to edit a page, I was not expecting the format of the editing box to look as it did. Before actually editing anything, I tried to familiarize myself with the code, figuring out how to read it.

Since I know I have assignments coming up for other classes, I started Project 2 this afternoon. It was shorter and easier than I expected. I had to look up and re-familiarize myself with inexact->exact, but the rest I didn't have a problem with. I used the timer2 code from October 17th and Picturing Programs to review key and mouse handlers. I'm just stuck on writing the check-expects for one definition and then I am done. I'm going to leave it for tonight and see if I can get it right in a day or two.

I still haven't picked an algorithm for an entry, but I think that will be my next post.

Tuesday, November 13, 2012

Term Test #2

It's been a busy week and I'm falling behind in my posts. I have a massive group report due tomorrow, on top of the second term test and I went home to work Thursday through Sunday. I've been reviewing the notes from the lectures and I find the material pretty interesting. I appreciate that I'm finally learning a little bit about how computers work. Hopefully the test tomorrow will be similar to the first test in difficulty.

I've also been thinking about a mathematical algorithm for my next blog post, but so far I haven't decided on one. Maybe I'll just wait until Thursday to pick a topic.

The due date for the third part of the Wikipedia assignment is also coming up. I'm a little nervous to start working on it, but seeing as I read the required pages for Part 2, it should go okay.

Wednesday, October 31, 2012

October 31st



                I enjoyed the tutorial exercises for this week. Initially I was stuck on how to define the functions in questions 9.2.5 and 9.2.6 for odd-numbered strings. I started by defining the function to take the first and last half of my strings and I wrote only check-expects with even-numbered strings.  My definition worked for even-numbered strings so I moved on to try to write it to accept odd numbers too. I looked back at examples and tutorial exercises we had done before, specifically examples on rounding numbers. My research paid off because the definition I wrote works for both even- and odd-numbered strings.

                Project #1 was posted last Friday so I started working on it over the weekend and I completed it today. It wasn't too bad, but I found it a little difficult to try to just jump in and manipulate the code already written. There were a few times that I got stuck but when I did I checked Picturing Programs, the DrRacket Help Desk, and previous tutorial exercises and demos from class. Often I found that checking these resources helped but sometimes I still couldn't get the check-expects to pass. When I got too frustrated with repeated failure I would stop working on it for a few hours, or even the rest of the day, and try again later, which also really helped.

Thursday, October 25, 2012

Models that aren't images?



                 This week when I tried the tutorial exercises it was like I'd forgotten everything we've learned. I was forgetting the basics like brackets and hyphens and I had trouble with the exercises. I had a friend show me what I was doing wrong though and I had no problems after that. I didn't spend enough time playing around in Dr. Racket this week, though, because the quiz threw me off a little. In all of the big-bang exercises we used a function with on-tick in the form of:

                (on-tick function-name interval)

The quiz used a numerical value instead of a function and I wasn't sure what that would produce. An error? Would the program ignore it? After the quiz I tried it to see what really would happen. I am going to practice some more using big-bang with models that are numbers not images to make sure I fully understand what I'm doing and hopefully I won't get stuck on any more quizzes.

              Last week we got our tests back. I'm pretty happy with the mark I got and I'm glad I didn't stress too much over studying. I wrote the test very quickly though, and I ended up missing one question. On the next test I plan to make sure I take my time looking over each question and my answers.

Sunday, October 14, 2012

Another tutorial exercise down...



I started the Dr. Racket exercises for tutorial #4 by practicing the code we had done in class with map and map-image. I created various lists to get familiar with using map and I defined my own function add5, mimicking add1, to add 5 to every number in my list. I also tried the functions previously defined in class (less-green and swap-red-blue) on a new image.  Then I moved on to defining my own functions to change the colours in my selected image. I initially tried to define my function so that red would be removed from every pixel but I was unsuccessful. I kept getting errors like:

                color-red expects a color, given 0

and my check-expect kept failing so finally I gave up trying to eliminate red entirely. Instead I defined my function to mimic less-green, but set red to be the quotient when divided by 10 rather than 2. After this worked I opened the Help Desk from Dr. Racket. I searched until I found an example of how to define a function that produces an image with one colour completely leached out. The definition in the example was written: 

                ; lose red: color -> color
                (define (lose-red old color)
                                (make-color 0 (color-green old-color) (color-blue old-color)))

I followed this example but rather than use 'old-color' I kept what we had used in class, so my function read:

                (define (remove-red c)
                                (make-color 0
                                (color-green c)
                                (color-blue c)
                                (color-alpha c)))

I ran this and applied it to an image. It worked! My test passed and it produced the image I wanted.
                I moved on to the next part of the tutorial, defining rotate-red-blue-green but had an extra set of brackets when I tried to apply it to my image and I kept getting the error:  

                color-green: expects a color, given #<image>

I looked at swap-red-blue and realized I didn't need  the brackets. I deleted them, ran and got the expected image.  I found the tutorial exercises good practice for getting acquainted with using map and map-image on my own.

Friday, October 12, 2012

The Why and How of Slogging

So far I am enjoying the course quite a bit. I have no experience in computer programming despite having a programmer in the family. At first I was unsure what the Dr. Racket demonstrations and tutorial exercises were leading to, but I'm beginning to see some of the possible applications.


I really appreciated the tutorial videos for the first two tutorial exercises. I found that they made learning the material and practicing it in Dr. Racket easier and more straightforward.  I started by watching the video once, and then watching it a second time while practicing the exercise in Dr. Racket in my own window. After I'd done the exercises in the video I tried the suggested exercises listed below each video.  At first I had some trouble defining functions in tutorial 2 to produce precisely what I wanted. I re-watched the videos and kept practicing defining different functions until I got the hang of it.  Of course, since I'm writing this a number of weeks after trying the exercises I don't remember specifically what I was having trouble with. My future entries will have to be written much sooner after trying the tutorial exercises. Regardless, I found that all of the tutorial exercises appropriately prepared me for the first term test this past Wednesday.

I liked seeing the application of what we've learned to create the barracuda "clock" in the Dr. Racket demonstration.  If I have extra time before we cover it in class, I'd like to experiment on my own with what was left on the wish list:

; rotate at the right speed
; rotate from (near) the tail

Changing the rotation speed of the barracuda to the appropriate speed of a clock should be easy now that we covered tick handlers and the interval in tutorial 3. Changing the point of rotation, though, will be something I'll have to look up.

Up until now I have found the Dr. Racket exercises fairly straightforward.  I am eager to start the next tutorial exercises and I look forward to seeing if exercises get more difficult as this course progresses.