Thursday, April 4, 2013

Weeks 11, 12:

WIth regards to project 2:
With Contrast.rkt --> This exercise was really easy to finish, but nonetheless interesting to work with.  Whilst in essence very similar to the ball.rkt work of project 1, this one had its tweaks that made it a bit more challenging, such as giving conditions, "equal?" (i still dont get them quite correctly, but if i have a lead, i can finish the problem).
With fractal.rkt ---> I was utterly lost for the first 30 mins of my time, as i did understood the check expects. Nonetheless after realising that the 2 values inside make-param corresponded to depth and height, i managed to understand how to make the definition. The rest was really simple, though i must remember about sub1 and add1, took me awhile to figure how to make the other sets of definitions to work.


With regards to the problem solving for slog: Quite simple, though i reckon i should have started earlier with this thing.

With regards to the course in general: Really enjoyable, and quite interesting for persons such as myself that had no idea on how to code in the first place.

Also, for some reason my drRacket crashes when trying to run a code.... i had some nasty cases of lost data.

Weeks 9 and 10


Things i enjoyed: working and finishing the wikipedia project. This proved to be a very satisfying work, and hopefully i did a decent job getting some of the translations correctly, as well as the appropriate citations.

Things that proved to be challenging: The midterm was kinda disappointing because I lost most my my marks   not on code problems, but rather on the other sections. Hence i must reinforce those areas when studying for the final exam. Also whilst recursion problems started reasonably easy, they proved to become quite challenging, in fact it took me a lot of time to understand the coding. Also migrating from intermediate student to full racket language was not an easy transition. Took me a while to realise why my check expects were not working.


Problem solving!


Penny piles problem:

Understand the Problem:

There are 2 drawers, left one with 64 pennies, and the right one without any:

The objective is to arrange the pennies so that one of them has 48 pennies, by following 2 steps:

L: If the left drawer has an even number of pennies, you may transfer half of them to the right drawer. If the left drawer has an odd amount of pennies, this step is not computable.

R: If the right drawer has an even number of pennies, you may transfer half of them to the left drawer. If the right drawer has an odd amount of pennies, this step is not computable.


Way of solving the question:

Draw a tree diagram on a piece of paper:
Pro: easy to sketch, easy to follow
Con: Takes a lot of time, especially for smaller odd values.



Solution:
1.     L -----à This leaves us with 32 pennies in each drawer
2.     L -----à This leaves us with 16 pennies in the left drawer and 48 in the right drawer.

Now, the question proceeds to ask to choose a value between 0 and 64, the chosen value will be the target value (x) to leave in a drawer.

Let x be 20:
1.     L -----à This leaves us with 32 pennies in each drawer.
2.     L -----à This leaves us with 16 pennies in the left drawer and 48 in the right drawer.
3.     R -----à This leaves us with 40 pennies in the left drawer and 24 on the right drawer
4.     L -----à This leaves us with 20 in the left drawer and 24 on the right drawer

Took more steps, but still more simple
Let’s try giving x the value of 4
1.     L -----à This leaves us with 32 pennies in each drawer.
2.     L -----à This leaves us with 16 pennies in the left drawer and 48 in the right drawer.
3.     L -----à This leaves us with 8 pennies in the left drawer and 56 on the right drawer
4.     L -----à This leaves us with 4 in the left drawer and 60 on the right drawer

Q&A:

Q: Are there any numbers in the range [0,64] that are impossible to reach?
A: Yes, the following values are impossible to reach: 0, several odd values such as 61 and 3.

Q: What about starting with a different number of pennies on the left drawer?
A: For numbers smaller than 64, each number will yield less possible numbers, whilst using any odd number will automatically make the problem void. With numbers larger than 64, some numbers may yield more numbers, but other like 70, will yield less.




Am i doing this right?