Wednesday, 27 November 2013

Man Programing can be Frustraiting!

In my efforts to finish the second project in this course I ran into some serious difficulty at first. I had forgotten some of what i had previously learnt about structs and so when the time came to use this part of my knowledge to finish the assignment i hit a wall. Thankfully, due to the numerous sources available to me I was able to work through my problems and finish the work. I ended up having to use a wide array of different sources of information to help me wrap my head around what i needed to do to make the program do what it was supposed to. First I refereed to the video tutorials Danny had made involving anything to do with structs. I was looking for the different commands that he used and the proper syntax to make them work correctly. This unfortunately did not give me the proper understanding i needed to apply them to the problem in the assignment. I next looked at the Dr Racket website where i used the search command to look up various commands to see examples of their use and other related commands. Afterwards I looked at Stephen Block's Picturing Programs to both look at example problems and the way in which they should be tackled and also for a much more thorough description of the way the commands work. With all this help I finally had a moment where suddenly the information all just clicked together and I had a moment of clarity.

Tuesday, 19 November 2013

Finding Solutions to Complex Questions

In class last week we were given a question problem where we had to come up with a solution to finding the greatest possible product from the sums of a number. I decided to try and come up with a solution for this question. The first thing i did was try to  look for any kind of pattern in the first few numbers in the sequences.
starting with 1, and increasing upward the best set of sums to multiply are:
1, 1
2, 2
3, 3
4, 2 + 2
5, 3 + 2
6, 3 + 3
7, 3 + 2 + 2
8, 3 + 3 + 2
9, 3 + 3 + 3
10, 3 + 3 + 2 + 2

I began to notice something, 3 and 2 seemed to be the numbers you wanted to use for getting the highest possible product. I hypothesize this has something to do with exponential multiplication in that the more you can multiply the numbers by anything higher than 1 the better overall. To then see if this held true for larger numbers i examined 30 to see if what i thought would be the right combination would turn out ot be true.

30, 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3; product of 59049
I am not going to write out all the other possible combinations, but  i will look at a few
30, 5 + 5 + 5 + 5 + 5 + 5; product 15625
30, 10 + 10 + 10; product 1000

There appears to be a correlation between product and the number of multiplicands there are in the sum.

With this information, i thought i would try and make a racket program that could give you the  highest product for any given positive whole number.

This is what i came up with:

; prod : number -> number
; takes a positive whole number and displays the greatest possible product that can be made from the sums of the number
(check-expect (prod 2) 2)
(check-expect (prod 5) 6)
(check-expect (prod 30) 59049)
(define (prod x)
  (cond
    [(or (equal? x 1)  (equal? x 2) (equal? x 3 )) x]
    [(> x 3) (cond
               [(equal? (remainder x 3) 1) (* (expt 3 (- (quotient x 3) 1)) 4)]
               [(equal? (remainder x 3) 2) (* (expt 3 (quotient x 3)) 2)]
               [(equal? (remainder x 3) 0) (expt 3 (quotient x 3))])]))


Wednesday, 13 November 2013

Preparing for Tests

The process of preparing for tests always bothers me in courses where definite answers are required. The majority of my courses at university have been in the humanities and as such, they tend to be much more open ended in the questions they ask. Sure there are word definition sections, but even something as black and white as a definition can leave much room to interpretation. Taking tests in courses where either you know the answer or don't are naturally frustrating to me. In this course, if I come across a question in relation to programing that i don't know (say i don't recall what one of the functions does) odds are i am not going to be able to just extemporize and hope to at least touch on some subject points that will get me at least partial credit. This is one of the reasons i did not pursue a degree in the maths and sciences, i am much better at open ended questions than i am at definitive ones.

My best hope is to simply review the course work and re do the practice examples for the various functions and commands we learn and hope that i don't suddenly forget what they all mean when i look at them on the test paper. I am glad that the tests in this course are more a mix of programming and the "history of computers" as at least with the latter there is some room for imaginative answers.

Wednesday, 6 November 2013

Challenging Assignments

The latest assignment, the one involving the completing the sneeze.rtk file was probably the most enjoyable assignment i have done in this course to date. Whereas the weekly quiz's and even the test relied much more on being able to comprehend programing code that is shown to us, the sneeze assignment required original work. I had fun trying to figure out what commands i needed in order to produce the desired result for each section of the program, it felt like i was piecing together a jigsaw puzzle. I would almost prefer doing this kind of work for the course on a weekly basis. While not as complex as being tasked with going out and creating a whole program completely from scratch, the fill in the blank format requires, i feel, just the right combination of comprehension of the programing units and individual initiative that allows one to feel as though they really accomplished something in the course. Not only can i memorize what a command does, but i can use it in a program and make something happen.