Thursday, 4 April 2013

SLOG Assignment


You are sitting in front of two drawers. The left drawer contains 64 pennies, the right drawer contains
nothing. Can you arrange things so that one of the drawers has 48 pennies, using combinations of the
following two operations, l and r?

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 number of pennies, operation l is disallowed.

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 number of pennies, operation r is disallowed.

Choose another number in the range [0,64]. Starting from the same initial position, can you arrange
things so that one of the drawers has that number of pennies? Are there any numbers in that range that
are impossible to achieve? What about starting with a different number of pennies in the left drawer?


Understand the problem.
- There are two drawers - Right and Left
- There are 64 pennies
- These 64 pennies are in the Left drawer.
- There are no pennies in the Right drawer
- You have to arrange the pennies in a way so that there are 48 pennies in one drawer.

Devise a plan.
- Start off with the 64 pennies being in the Left drawer.
- Divide the number of pennies in half and carry it over to the other drawer
- Continue this until you have 48 pennies in one of the drawers
- Create a flow chart to better understand the steps of this process.

Carry out the plan.
- The Left drawer has 64 pennies and the Right has none,
- Since 64 is a even number, 32 of it will be transferred to the Right drawer
- Assuming the the drawers will take alternative turns in making the transfer, this time the transfer of half the pennies will be made by the Right drawer.
- At this point, both drawers have 32 pennies
- Right transfers half which is 16 to the Left drawer
- Now, Right has 16 pennies and the Left has 48 ( 32 from the previous step + the 16)
- This goes on until we reach the combination 43 -21 which is when neither of the operations are allowed.

Extra 

- There are no other numbers other than 64 from 0-64 that you can start with in order to have 48 in one drawer other than when you start with 48 in one and 0 in the other. This is assuming that you always start with 0 pennies in one drawer and the multiples of 2 in the other drawer.
- If you try other combinations, since one of the drawers must always have an even number of pennies to make sure that they can be equally divided, the other drawer automatically ends up having another even number of pennies . As shown below.

 64-0, 62-2,60-4 , 58-6, 56-8, 54-10, 52-12, 50-14, 48-16, 46-18, 44-20, 42-22, 40-24, 38-26, 36-22, 34-30, 32-32, 30-34 .......

You can see a pattern here: Both numbers are always even. why ? Because in order to make one drawer even, to make at least one operation allowed, you end up taking away an even number of pennies from 64 all the time. And when you take away even numbers from bigger even numbers, you only end up with more even number since all even numbers are multiples of two!


Look back, figure out when and how you're stuck.
- I was stuck in the very beginning while thinking about how the drawers will alternative in the exchange, if they will.Then I realized that it does not matter since the requirement is that any one of the  drawer contains 48 pennies.

Wednesday, 3 April 2013

Week 11

No tutorial !! :O yay ! no offense to the TAs .. we love you very much !

This week was about work. Work hours and how computers has changed the nature of work. We can now get things done faster and more efficiently, we work without even being at the workplace, we have machines to do the hard labor etc. All in all  whether computers have made the work environment a better place (utopia) or a not so better place (dystopia).

Week 10

This week we learned about operating systems and network ! The more interesting thing this week was however the recursion ! It was just the Sierpinski triangles where you had a condition but this was way more interesting since this time we learned to make it do so many cooler things !

Moving on... This week was also when part three  of the Wikipedia was due. Although I had picked 4-5 pages to edit in the first stage of the project, I later realized that despite the fact that these pages were marked as needing copy edits, when I read through them, they seemed to not be needing any. So I ended up editng only 3 of them.  I added more information to one page that was on a film, one on the new Indian rupee symbol and one on a sports stadium in Asia. I actually received feedback from one editor asking me to make sure I completed the edit summary and also gave me few other tips. I have to admit , I found this project very engaging and rewarding when I found out that the new wikipedia pages for the ones I edited contains my contributions especially because I knew a couple other people who were complaining about their work being deleted , Overall I really enjoyed this wikipedia assignment and I think that I really did contribute to that community which was the purpose of this assignment in the first place.

Friday, 22 March 2013

Week 9 Term Test 2

A sierpinski triangle? what on earth is that ? well its the name of the guy Wacław Sierpiński who described it in the good old days of 1950s. First when I looked at the program and saw the word, I naively tried to find what the sierpinski function does on the Dr Racket manuals found online but to my dismay, there was no sierpinski function... well then what was it ? it was one of those functions  you "create" and tell it what to do and not a predefined racket function. Well anyway it basically just puts triangles on top of each other to get the distinct sierpinski triangle  as you see on the left here. Its kind of like the inception movie because the code adds layer on top of a layer each time to make  sierpinski triangle deeper and deeper or just larger and more complex. It was pretty cool I would say.


Now onto a less cheerful subject, the Term Test. dun dun DUN!!! I wrote all the number and hardware notes on my cheat sheet, examples of check expect statements, binary conversions and everything else we needed to know and I was on a pretty good roll during the test or that was what I thought.  I had all the answers right in front of me and I was filling them all in but then unfortunately we ran out of time which was really unfair because I had the answers but no time to write them down. Maybe next time we should get maybe an hour and a half to write it, and maybe in another lecture room so we do not have to rush to get out so the next class could get in. So it is my humble suggestion to the authorities reading this to consider more test writing time ! please !

Week 8

This whole week was spent stressing out about Project one .

The biggest problem was getting it to bounce back once it reached the end like it was originally programmed to do!! After much frustration and head scratching and on the day of... we, meaning me and my brilliant partner figured out that we were entering the wrong x and y values this whole time and we never told the program what to do once it reached the bottom of the window. Well that was stupid ! and the fox and mice program .... that was a whole other catastrophic !  But when you have a relentless partner like mine, shes going to make sure the job gets done !

Week 7

This week was all about the number ! binary , integer. integer, binary. at first it was a lot to take in all the zeros and all the conversions but in the end , it was pretty simple once you get the concept of it. To be honest, I actually did not understand when Mr.Heap taught it but eventually i got the hang out it when I watched this you tube video ! Oh and the part two of the wikipedia assignment. Just like the several other times i first started freaking out reading the instructions the part two ( i seriously think it the very official restrict sort of font its written in. They should consider a more friendly font like comic sans or something) but it was just basically reading the Help section of the community portal and writing a plan about how I am going to use that information to do the actual edits. One last thing, the quiz , on struts... well that too took me a while to get a hang of ( maybe im just slow o.O) but the whole concept was that one variable is pretty but like  a library that holds a bunch of characters - words, numbers, pictures, and then a list function pulls these characters out of the "library" and displays them when the user asks for it.

Friday, 15 February 2013

Week 6


Finally a blog on time!

This week we learned more about how computers store and output information using the Boolean logic plus the binary method and how computers use them to process information. Maybe all my hard work trying to figure that out last week was not a waste after all. Overall this week went pretty smoothly, the prof taught how to add binary numbers in class and since I already knew that the lecture was a breeze. 

As always I watched the tutorial videos the night before the tutorial but I caught on pretty quickly with the list, list-ref, structs, etc. On the morning of the tutorial me and my friend went through the videos one more time and discussed our questions and doubts among ourselves and went to write the quiz which I noticed to have gotten a little bit more challenging than the ones before this. The questions were not as obvious and more detailed plus now we were required to complete 5 out of 6 questions whereas before it was only 60-70% of the questions but I am not complaining! 
                                                   

Week 5 - Term Test !!




Not a lot happened this week other the term test madness. I was surprised that the term test just popped up out of nowhere because it was not even around the time midterms start. As I looked at the term test from last semester I thought to myself maybe this course is not as easy as I judged it to be. Seven pages and questions worth 5 and 10 marks? YIKES! I was confident about the computer history and the definitions-expression part of the test but not so much with the scary 10 mark question where you had to provide a check-expect statement, contract comment, and completing the define statement and body of the definition... Just the question sounds intimidating, not to mention the fact that I was not even quite sure what some of terms even meant. In the process of preparing for this test, I spent a good 2 hours trying to understand how to add, multiply, convert to integers the binary numbers only to realize the morning of the test that it will not even be on the test. (Jeez! I should really check my webmail more often!) 

The test was in fact challenging and I messed up big time on the 10 mark question just like I had predicted… Should have spent more time on figuring out that question than on the binary numbers that was not even on the test....

Week 4



Week 4... hmm. ah yes! The history of computers! 

This week we learned about how modern computers we have today came about in existence. In class the professor started talking about how clay tablets were the first computers..! Yes, clay tablets because the definition of a computer includes a device that is capable of storing information that can be retrieved later, and since clay tablets were capable of accomplishing exactly that, they are considered the first computers. Who would have thought?? Then it was the abacus which were beads on wires or rods that was used as an early calculator. I remember when I was a kid, I was enrolled in this special abacus school where they taught how to do math using only the abacus (I still do basic math in my mental abacus sometimes!) After that were looms that was able to read patterns off of punch cards and mimic that,  and engines (with the invention of the steam engines), and then came the first "computers" as we know today. These first computers were powered by steam in glass tubes which had numerous disadvantages leading to the use of transistors to replace glass tubes.

Week four was also the week part I of the Wikipedia assignment was due. When I first created my account and followed the instruction posted on the course webpage I was completely disordered because there were just so many links and so many sub categories. After much frustration and a power nap I read the instruction one more time and realized that the assignment is not as complicated as I perceived it to be. Finally I selected a couple articles that I wanted to work on including one on a really old Indian movie featuring one of my favorite actors (yay!) and submitted it on MarkUs.

This was the first time we had to actually had to read the Picturing Programs textbook for a tutorial and surprising I found it quiet helpful than the videos because the book has more examples and its easier for me to refer back and forth to it when working on the exercises. Maybe I will use the textbook more often! 

Monday, 4 February 2013

Week 3


I know... it’s a bit late for week 3's blog but I never had the time till now so here goes. 

Week 3 has been the most productive week for me so far because I was able to catch on quickly with this week's lessons and had a triumphant time with the activities.  We learned about definition, or in other words, defining identifiers for images, numbers, words, etc. I always find it fun to work with images because it gives me the freedom to use an image of my choice which gives me a little motivation boost to do the activities. Two of the many activities we had to do for this week were:

1) Calculate the sum of 149 divided by 7 with 83 times 15.
2) Append the first six characters of "sixty-five" to the first two characters of "twenty"

And I have to admit, after several failed attempts at doing this with no help what so ever, I felt like an absolute genius when I got it right!

Solution for #1 
> (+ (/ 149 7) (* 83 15))
>1266.285714

Solution for #2
> (define one "sixtyfive")
> (define two "twenty")
> (define first-six (substring sixtyfive 0 6))
sixtyfive: this variable is not defined
> (define first-six (substring one 0 6))
> (define first-two (substring two 0 2))
> (string-append first-six first-two)
"sixtyftw"

First, I was absolutely lost because I was so confused as to where the brackets and the math signs go but I found A 'Dr.Racket Manual' online which showed me just how to write those math functions.  For question number two, however, I did not know what function to use and was not able to find it on this online ’Dr.Racket Manual'. So, I felt especially smart that I came up with the idea of creating place holders or identifiers for each of the words that were to be used in the 'string append' function and ever more so when I later found out that this method wasn't even taught in class for 'string append'. Yes, there is a simpler and much easier way but still I figured it all out myself using only what was taught on the videos so I am going to keep up the pride.

Later that week we had a tutorial quiz on which a new function was created called 'sandwich' with its definitions and we had to figure out what that function would do in a certain case. Since I was familiar with this tactic (thanks to my ingenious moments with the definitions activity) I was able to seamlessly ace that quiz!   

Tuesday, 22 January 2013

Week 1-2


First 2 weeks of CSC104... 



My first reaction to this course was "uugghhhh its too early in the morning !!" Living almost 2 hours away from campus, getting to a lecture at 9 AM in the morning in the harsh January winter is close to torture. By the time I get to class, Im cold, sleepy from waking up too early and hungry from not having the time to grab breakfast in between the morning rush. However, I perform the same streneous task three days a week regardless of the pains for the sake of learning the "How and Why of computing" and for the sake of taking a course with my best friend of 15 years.
Now shifting the topic to the actual course material, I found the simple functions of "flip-verticle", "image-width" almost effortless and obvious having a basic knowledge in the Turing program.

One week later, it was time for the first tutorial. After a long day of work , I came home to take a look at the videos on values and try some of the exercises for myself, only to repeatedly receive a "function not defined" error message. After several frustrated attempts, I decided to call it a day in order to get to the lab in time the next morning. The next morning, after aimlessly trying to find the Bahen building in the ruthless cold, my friend and I ended up in a crowded lab with no available computers. I managed to put my time with the TAs to good use and figured out the reason behind the annoying error message I kept receiving (I had been entering function on the wrong side of the split screen without remembering to press 'Ctrl R'). Thirty minutes later I wrote a surprisingly effortless quiz on the functions well discussed in lectures and walked to the subway hoping to learn more challenging functions to add on to my pre-existing knowledge.