abracodeabra
abracodeabra
I put the 'gram' in 'programming'
5 posts
Don't wanna be here? Send us removal request.
abracodeabra · 9 years ago
Text
SLOG week 7 (Recursion & Retirement)
This week, we learned a bit about recursion. Quite an exciting topic! What’s even more exciting is my pension funds are coming in this week now that I’ve retired! I plan to spend my part of my funds on presents for my grandkids, however I’ve run into a few issues. I don’t want to surprise them with presents that I chose, so I want to ask each of them what they would like. However, I’d also have a hard time trying to keep track of which grandchild wants which present, and it’s a tedious task for me to ask each of them what they want.
 Fortunately, I’ve figured out how to ask each of them what they want as their Pension Present (hereafter PP) by doing the least amount of work possible! The plan is to order my grandchildren from oldest to youngest. I will ask my oldest grandchild to: a) tell me what PP they would like the most, and b) tell me what PPs that the younger grandchildren would like. In order to know the answer to part b), the second-oldest grandchild would need to know what the third-oldest would like, and so on, until there are no more “older” grandchildren (we’ve reached the youngest one!) 
It becomes clear that none of the grandchildren can actually fulfill part b) until we’ve reached the youngest grandchild. We cannot obtain a list of all PP immediately, we must first create a stack of questions from the oldest child (bottom) to youngest (top).  The stack of questions will be in the form of “I want a ____ for my PP, but what do(es) the younger grandchild(ren) want? ______.” 
Tumblr media
Once we know what the youngest grandchild wants (Daniel wants some white vans), they can start building a list of gifts by answering the questions they asked that required the younger grandchild’s response. The list of responses starts at the top of the stack (youngest child) and grows until we reach the bottom of the stack (oldest child). 
Tumblr media
 Once it reaches the oldest child, we have a list of all of the PP in order of oldest to youngest grandchild, and it required me to talk to only one grandchild! Using this method of recursion is much more efficient for me in comparison to going up to each grandchild and asking what they would like. 
Seeing this “efficiency” reflected in code, although the lines of code become shorter, I wonder if recursion has any effect on the runtime in comparison to list comprehension or a for loop. Would it be faster because there are less lines of code? Or slower because it needs to create and remove a Stack? Maybe it would stay the same? Would it use up more memory than looping an “append” method to a list? One thing that I know for sure, is that my grandkids will love their Pension Presents! And they will love their Grandma…or just her money. Retirement is great.
7 notes · View notes
abracodeabra · 9 years ago
Text
SLOG week 6
Did anyone finish writing the midterm that took place this week? I felt like it was incredibly long and intensive to write in only 50 minutes! My poor, aching grandma wrists had a difficult time writing out all of the APIs and implementations. I wish that the API was given for some of the questions and there were more questions on tracing, rather than writing and implementing classes. I feel like being tested intensively on API should be less emphasized on the test and more emphasized in the assignments. I feel that the test should focus more on implementing code and problem solving. 
As for assignment one, I can see realistically how we could program an app to simulate ridesharing. Some things that could be improved upon for future projects are to use shortest distances using winding roads with curves, as opposed to Manhattan distance. The driver could also get the cost of gas and the cost of the total ride on a meter. It would be fun to try implementing this sometime in the summer with my grandkids! I could use the ridesharing simulator to send them as far away from me as possible when I’m done with programming the app and I can keep the profits all to myself. #GreedyGrandma
 I’m looking forward to learning about recursion next week. I’ve had a little bit of exposure with recursion, it feels as if the implementation of the function is becoming more concise, and can be written in fewer lines of code. For now, I’ll continue finishing the assignment with my partners.
0 notes
abracodeabra · 9 years ago
Text
SLOG week 5
So this week, I used that nifty Mandarin coupon that I found somewhere in my messy Sack-Purse along with my senior discount at the Mandarin restaurant buffet. While I was anxiously waiting for a seat to enjoy my unlimited crab legs, I noticed that there was an ordered line of people waiting to be served. Whoever was at the front was given less of a wait time to be seated and they were dealt with first. It was only until the first person in line was served until the Hostess could move onto the second person. There was no way for the Hostess to serve the people in the middle or end of the line, or should I say, Queue. Whoever came earlier was served earlier, and the rest of the people would wait until whoever came first was served until it was their turn. Unfortunately I can’t really use my senior privileges to get ahead of the line but that discount sure makes up for it! 
This gave me an idea for implementing a Queue in the doctor’s office. When people are waiting for the doctor for who knows how long, couldn’t they obtain a “buzzer” to alert them when it’s almost their turn? Then they wouldn’t have to wait for so long in the waiting room and instead could go use their time to run errands or do some shopping. I realize now I have the skills and ability to program an app that could manage this. 
When I was in Mandarin, I met a handsome younger fellow in his nineties #CougarAlert and we exchanged numbers! How exciting! Although he’s younger than me by a few decades, his method of recording my number down seemed more primitive than mine. He pulled out an older address book and it was written in alphabetical order. When he wanted to insert my information into the address book, He had to erase all of the people succeeding my name and rewrite them a space below. It took an unbelievable amount of time, energy, and memory for him, similar to inserting something in an ordinary list structure.
 What I did instead was use an app that my grandkids programmed for me on my phone that used Linked Lists. Each contact could be represented as a Node, and each Node points to another Node. If I wanted to add Guy H. Andsome to my contact list, and if it were organized by first name alphabetical, I would have to insert his position between Gina and Hilda. Instead of moving everyone from Hilda downward, all I would do is change Gina’s pointer to Guy and create a pointer for Guy, which points to Hilda. Everyone including and after Hilda would remain unchanged. And in case things don’t work out with Guy and I, deleting him will only require deleting his node and changing Gina’s pointer to point to Hilda. Much more efficient to use Linked Lists than ordinary lists if you want to insert information in a specific spot.
1 note · View note
abracodeabra · 9 years ago
Text
SLOG numero dos
<werenotlearningHTMLarewe>
As you might know, I am quite the grandma and am not as fast as the youngsters in their ability to post on their SLOGs ( I guess that makes me a SLUG? #grandmahumour ).  I usually write my SLOGs on the TTC, no wireless, no reception, no dial-up, no fax machines for the public on the subway. I might be a bit late in posting these SLOGs, but at least i’m not late when it’s time to take my medicine! 
Anyway, during CSC148 week 4, we learned about new data structures like Stacks and Sacks. Let’s start with a stack. I have a stack of vintage vinyl records somewhere in my attic. They’re ordered sequentially, in the order where I obtained them when they were originally released. I have artists like Ella Fitzgerald ( 1958), Dick Dale (1962) , The Beatles (1970), Queen (1975), and Drake (2014) (Somehow there is a vinyl record for that, my grandkids listen to him, not me). Now if I decide to listen to a record, it’s much easier to pull off the top record (Drake) than any other record in the stack. But what if I want to listen to Dick Dale? My tired old bones and atrophying muscles won’t allow me to remove a record from the middle of the stack. It would just fall over and make a mess. So I can only remove whatever is on the top of the stack multiple times. I should first remove Drake, then Queen, then The Beatles until I finally get to Dick Dale.  I can still listen to my older records, but it requires so much effort and arthritis medication. It’s fortunate that I have youtube to relive my girlish nostalgia. 
Tumblr media
Where did I put my arthritis medication anyway? Somewhere in my purse...Let’s see... car keys... expired candy... mandarin coupon... I can never find anything in this old Sack! The order of these items in my purse are always randomly mixed and there’s no telling what i’ll pull out next. The last thing I put in my purse was my arthritis medication, but it doesn’t matter what I put in first or last because there’s no order in my purse. If I want to get to my arthritis medication, I don’t know how many random items i’ll need to pull out until I get to it. Sometimes I get my medication on the first try and sometimes I have my whole purse emptied out. 
Tumblr media
Other than learning about Stacks and Sacks, I feel like the 148 course is going well. I see more emphasis on writing doc strings and the API than I do with implementing the code. I’d like to learn more about the advantages with a Sack as opposed to a Stack. Maybe the structure aids in understanding probability more so than a Stack would, as the order of removal is random? 
</werenotlearningHTMLarewe>
0 notes
abracodeabra · 9 years ago
Text
SLOG numero uno
<thisisntevenpython>
Sometimes I really do wonder how much revenue the folks at tumblr are generating from all of these csc148 blogs... and then I wonder how many of us they're going to recruit. Besides that, I'm currently in the third ish week of taking csc148, it's not too bad... (yet... ok well that really depends on my habits right? #prayforpOST). One of the things I remember from taking csc108 that I hope will change in csc148 is that we tended to just write programs that completed compartmentalized functions but we never really could visualize how it all comes together when executed. That part would only come in if we ran a tester file which was given to us completed for the assignment. As a programmer, it felt like I was making bricks but somebody else cemented them together and I had difficulty visualizing how it all came together.  I hope that in 148 I will be able to cement the functions together as well. Another thing that I really like about 148 is the introduction of the turtle in python. I'm a visual - spatial person and now I can see the bare basics of  how people can code for platform games this way. I'm looking forward to using the  turtle builtin more in the future. something I don't like as a change, however, are the new type contracts we use. It doesn't seem as efficient however I am hoping I will see its usefulness later on. maybe I'll also figure out how to better close my SLOGs.
<\thisisntevenpython>
2 notes · View notes