Thursday 17 December 2020

Reflection on my CS50 journey so far

After finishing the Week 5 Problem Set, that's generally the end of learning how to programme using C. From the next week onwards, I'll be using other programming languages such as Python and SQL. From the sound of it, using Python will be a lot easier compared to C (really hope so).

I read from a blog written by someone who has completed this course, that C is an on-the-ground-level programming language, and because of this, understanding what's happening underneath the "hood", understanding what the computer does when it receives a specific code that you typed in would be essential. But for Python, it is a programming language that has integrated programmes that people have wrote, and to use these programmes or functions, we just need to type a shorter and simpler syntax to get the computer to do what we want it to. Not sure if this means that we can just ignore the idea of memory and data structures which gave me a hard time completing the problem sets.

Anyways, I've been thinking about what I'd like to do for my Final Project, although there are still many weeks of lectures and problem sets to complete before I even get there. I've thought of two major ideas.

The first one is making an app to track budgets and spendings. There are probably tons of apps out there that do this, but I wanna make it personal for my own needs and use. I want it to be an app that helps me plan for my future wealth, other than just tracking how much I spend. Up until now, I've been collecting receipts and checking my online bank account for any purchases that I did. I also record from where the receipts are issued to get a sense of the type of item I usually spend on. I also make notes on the large one-off spendings that I make like buying the SAMSUNG Tablet or traveling for leisure. 

Back in undergraduate, I used to have a cap on how much I should spend in a month, and how much I managed to save. But now, not anymore since I don't have a running source of money, just the savings that I have. But once I do, I want to be able to know how much I can spend and how much I should save each month for important things like car insurance, taxes, loans, and wish-list savings. I want to know how much should I save if I want to perform the Hajj ASAP, or if I wanna travel around the world. All without jeopardising future wealth. I'm not working yet, but I think it's important to have a system that allows you to calculate how much to save to allow you to pay for things like annual payments or having funds for emergency situations like sending your car to the workshop (which is unexpected) or paying for emergency medical expenditures. Even worse, having enough savings for a pandemic, like what we're facing now, the COVID-19 pandemic.

After these 6 weeks of CS50, I think I kinda have an idea how some apps work. I'll use the example of a period calendar/tracker (haha! I'm not even sure why this came first to my mind). I'm not gonna go through the entire functions of the app, like the forums and stuffs, just gonna go through the part where we have a calendar and we put in when we're having our periods, and when we have symptoms like spotting and mood swings.

So first of all, we have the calendar. I think the calendar is a hash table that stores many variables. Other than variables, it also stores the address where it can access the values we added, so that whenever we want to view the info we saved into a particular day, we just need to go to that day, and the app will show all the info stored under that day. Imagine that all the info are connected like nodes in a linked list, and there are additional functions that copy the values so that it can display all the values to us by the end of the linked list.

Imagine all the dates in the calendar as an array of buckets to be filled in with info

When we access one of the dates, we are redirected to a linked list of variables

To add data, the programme is going to allocate just enough memory to do it. Like, obviously, we won't be using all the dates available in the calendar since there are days we're totally fine. Allocating and using unnecessary memory to store nothing is just ridiculous and memory space-wasting, so I guess, the programme will also frequently malloc-ing and freeing memory when we're done using it.

Not sure about the visual representation of the apps though. Like how do they design the icons and stuffs? I kinda get the idea of printing stuffs out, but not sure about how they do it beautifully and aesthetically. Maybe manipulate some bits, combine the three basic colours to make images? I'm not sure if this is gonna be taught in the course, but I hope they do.

The second one that I'm thinking of doing is developing a webpage that helps students do econometrics or illustrate Economic theory using specific numbers (since a lot of stuffs are done using algebra at higher level). Some people may not have a strong background in Maths (I've seen people struggling in my Master's programme because of the Maths), so having a website that can show step-by-step procedures in calculating values would be nice. Especially for problems that involve matrices. If I can also make accurate diagrams based on the input that the user gives, that'd also be nice. I'm envisioning an interactive Economics learning website.

So those are the ideas I have so far. Will see if one of them is feasible to do, or I may need to come up with new ideas. 

Tuesday 15 December 2020

CS50 Week 5 (14/12/2020)

Following the completion of PSet 4, I took another two-week break from CS50 because I wanted to focus on my research proposal write up and completing my Financial Econometrics assignment. After finishing Financial Econometrics Assignment 5, I immediately opened the edX webpage and head over to CS50 Week 5 to watch the lecture.

So far so good. I was able to answer questions whenever the lecturer asked questions to the lecture attendees, though my answers won't reach the lecturer since it is pre-recorded. But when I began working on the first part of the assignment Speller, my brain felt blank. I kept staring at what I wrote down (the to-do list) but I can't seem to comprehend what I should do to achieve them.



I began thinking (again) that I am not fit for this course. The thought of quitting hits me really hard. I began Googling whether I should do it or not. Fortunately, the internet community is very supportive and they encouraged people who had the same thoughts as me to endure it, and we'll definitely gain a life-changing experience out of the course.


When I wake up the next day, I reread the lecture notes and watched one of the shorts videos on Hash Functions to gain a better understanding of what it actually is and what it actually does. Reading the lecture notes helped me write codes when I need to connect nodes for the hash function while watching the shorts helped me understand hash functions better.

In short, hash functions are actually an array of 'buckets' that store numbers. These numbers represent a string, calculated using a function (can be anything, but easier to use an established hash function that has been written by someone else). When we pass a string into the function, the function generates a number, and stores this into one of the buckets. Whenever we want to check whether the string exists or not in one of the buckets, we just have to find the bucket using the same number, and check whether the string is stored in there.


I had so many segmentation faults, but it was mainly because I typed the wrong 'stuff', so the computer was searching for something that doesn't exist, to begin with. But after correcting it, the programme ran smoothly. Yet, that was not the end of the problem.

When I checked the output of my programme, my Speller doesn't consider a word with full capital letters the same as the same word with lower cases. After searching for answers to this problem online, I realised that it was because my hash function was dependent on the ASCII values of each character of a string. The ASCII value for a capital letter is not the same as the one for the same letter but of lower case, so the words "word" and "WORD" would have different numbers generated by the hash function, and so, Speller considers these words as two different words.

Once I fixed this, I was finally done. Alhamdulillah.



Monday 30 November 2020

CS50 Week 4 (30/11/2020)

I decided to skip one week of CS50 since I wanted to focus more on my Research Proposal and "prepare" for the Financial Econometrics test. After two weeks, I'm back. This time, with an introduction to Memory, Pointers, and Files. I remember that this was the thing that I had difficulty understanding, and I still do. 

The part on Memory was quite easy to understand, and I think I have a better understanding of Pointers now, but I'm still not comfortable with Files. While doing the Problem Set 4 Recover, I had to make notes and rewatch some parts of the walkthrough several times, because I wasn't sure how and at which part of the codes to use it.

Well... here it is... my progress.


Halfway or not???

I didn't get full marks for both problems in PS4

Overall, I think Filter was a lot easier than Recover, despite having more to do. But it didn't mean that I got everything correct on the first go. Like, for the Blur subsection of Filter, I made a bug while writing the codes. I didn't realise that my output would produce wrong answers because I was using altered values for Red Green Blue pixels as part of producing a new blurred image when I shouldn't. I thought that I did something wrong for the algebra, but I didn't. It was just a bug that I had to fix by creating a temporary image or a copy of the original image, that I can alter without having problems using the wrong sets of Red Green Blue pixels by using the values of the original picture, and not those of the copy.

My strategy for implementing Blur in Filter

As for Recover, after getting several Segmentation faults and blank images, reading through Stack Exhange and Reddit to find out what's wrong with my codes, I managed to get everything correct eventually, though upon checking my gradebook, I realised that I didn't get full marks for both Filter and Recover due to style.

What Style50 suggests me to do in order to avoid lengthy codes in Filter

After checking my submissions on Style50, I found the reason for the non-full marks. Apparently, for Filter it was because I was writing really long lines of codes, and I could've made it shorter by using the command for "Enter" using '\n' and that wouldn't affect my codes. This is something that I should use in the next problem sets if I need it.

I have no idea why this is suggested because my codes already look like this before Style50 suggested it

But I'm not sure about the style in Recover. Maybe this all happened because I kept copying and pasting stuffs around, so the gaps are all around the place. Although visually, I see gaps, but the computer doesn't, so I guess this was inevitable.

Okay, so that was it for Problem Set 4. I will be back for next week's materials, InShaAllah.


Monday 16 November 2020

CS50 Week 3 (16/11/2020)

The mid-semester break has started. It's a bit earlier than normal. Normally there will be 7 weeks of lectures before we get a mid-semester break, but for this semester, due to the COVID-19 that still has not subsided, and also probably in conjunction with Deepavali, our mid-semester break happens after the first 5 weeks of lectures.

I was busy with my Financial Econometrics assignment 4. It was on Cointegration and Toda-Yamamoto causality test. Choosing the appropriate model was hard for me because I was not sure when a model is considered free from autocorrelation. But since Prof said that marks will be given based on efforts and not on precision, I guess it won't hurt too much if I got the model specification wrong (add extra lags, or in short of a few lags). I think the most important thing is to clearly present that you understand what you run on E-Views and then you can express it well in algebra.

I did my Financial Econometrics assignment until Saturday, so I only began doing CS50 Week 3 on Sunday. I also began doing the problem sets on the same day. For Problem Set 3, it was the most challenging Problem Set so far, mainly because both the questions that I needed to complete and submit were new to me. They were nothing like the ones that I did in 2018. Well... the concepts are the same, but the questions are different :P I guess, since essentially, I'm still learning what I've learned before. If I'm not mistaken too, the next topic will be the most challenging one, on Pointers, I think haha~ maybe yes, maybe not. Whatever it is, I'm gonna prepare both my mind and body to endure the difficulties that are to come next.

Screenshot for Question 1 (Plurality) - the wrong code I've written

For Plurality (and also for Runoff), I didn't use any physical writing on a paper (or a tablet) and I did all by mental calculations and logics. I guess I didn't need it since I can just imagine what happens in the programme in my head. Everytime I wrote down a section of the codes, I go through the codes again, and think deeply about what things I may miss out, or what exactly happens to the arrays of variables that I have. I'd find bugs when I think like this, just like the one found above. If you look at the terminal (on the bottom of the screenshot), I purposely input in a way that everyone (Liyana, Syahirah, Amal and Nabila) would have similar votes, so if the programme codes are correct, everyone's name should be printed out. But only the first and the final person's names are printed, showing that there's something wrong with my codes. So I had to work on the codes again, until I get them right.

Screenshot for Question 2 (Runoff) - the wrong code I've written

For Runoff, I faced sooooo many problems. I think almost all of the sections that I worked on didn't work the first time I computed the codes. They just seemed wrong. But after re-thinking of new algorithms over and over, alhamdulillah, I finally finished this question too, completing my submission for Problem Set 3.

Problem Set 3 Complete!


Okay, I'm gonna take a break from CS50 while I work on my Master's Research Proposal. I've been making slow progress on it. Still haven't finished the Literature Review. May I make substantial progress on my Research Proposal over this mid-semester break! Ameen~

Saturday 7 November 2020

CS50 Week 2 (07/11/2020)

This week hasn't really as I hoped it to be. I've had to go out of the house a lot, to send parcels for courier and also to buy household necessities. These took quite some of the time that I could've used for studying. But the most disappointing thing about this week is how I've been watching YouTube or Facebook videos before I start doing work, and you know how these videos can be addictive. It's one after the other, and then you realise that you've already been too long on social media/internet. 

I had coursework to do, of course, for Financial Econometrics. I did that but I guess it's because I'm not used to reporting time series results, it took me too much time to finish it. I began doing it on Wednesday (the day after lectures) and finished on Friday night. Huh... really took a long time on it.

On Saturday (today), I decided to do CS50 Week 2. I definitely needed the refreshing of my knowledge since I had the wrong idea of what arrays are on C. But nevertheless, things seem to be more clear to me and it does show how "better" I became at writing codes. I was able to write down the codes without having to search for tips on StackExchange or the likes of that. Alhamdulillah.

To my surprise too, I was able to complete a problem that I've never done before, which was "Readability" (I'm sure I didn't do this one during the 2018 session), though not really something I should celebrate since I didn't get full marks for this (I don't know what's wrong with that one particular thing, ugh). But one thing that I'm a bit skeptical about myself is that my level of attention and focus is a lot more intense when doing CS50 compared to when I'm doing my Master's stuff. I guess it's because when I was doing CS50, I have that urge to finish it ASAP so that "I'd have more time for my Master's" added with the fact that I've used up a lot of time just for Financial Econometrics the days beforehand. 

                                        

Notes that I wrote down for "Readability"

Done Problem Set 2, albeit didn't get full marks

Alright, hoping for a better week ahead :)

Sunday 1 November 2020

CS50 Week 1 (01/11/2020)

This weekend, I nearly forgot that I wanted to dedicate my weekends to CS50 if my other (more imperative) assignments are in pretty good shape. To be frank, I think this week has been really unproductive. I had my period and I had a terrible menstrual cramp. I took 6 tablets of Panadol Menstrual overall, though normally I only took 2 or 4 to ease the pain. So, for one of the days, I really did not do much. As for the other days, I did something, but I wasn't pushing myself to do as much work as I should. I took more breaks and these breaks were a bit longer than they should, sometimes extending to more than an hour. I also did more drawing than I should, I guess.

So for next week, I hope I can improve on my time management because ideally, I would like to finish my Master's research proposal ASAP, get feedback ASAP, and begin collecting data ASAP. On the other hand, I feel like I am procrastinating a lot because I "have a lot of free time" since I'm only doing one module this semester and I have the research coming along. That's one of the reasons why I decided to restart doing CS50, to have more intellectually stimulating things to do. But at the same time, doing all of this is not occupying enough of my time (so far since the semester just started anyway), so I have a feeling that I may become better at time management if I work part-time. Ugh~ but I'm not sure whether I should work when my proposal is still blank pages. So I'm kinda procrastinating the work part too!!!

But on Sunday afternoon, I felt like I should work on CS50 Week 1 because I have a feeling that I will neglect CS50 altogether if I skipped doing it this week. Eventually, I did CS50.

Alhamdulillah, I managed to finish all the exercises for Week 1. I think the exercises are similar to those that I've done before (I chose to do the easy ones like before, too, since I'm not confident that I can take on the harder ones). There's a really small change to the exercises, and I think that's it. But funny enough, I still had to do a lot of thinking and try-an-error before I eventually get the codes right. 

Progress so far. Nice to know that we still have the choice to do easier ones or harder ones, depending on our comfortability.

My personal scribbles for one of the problems in Problem Set 1

Alright, now that that's put aside, I can go on to the next week without any regrets. Let's hope for the best! Ganbatte!

Saturday 24 October 2020

Restarting my CS50 online course from SCRATCH (pun intended)

A few weeks ago, I had dinner with a group of friends from Taylor's College. They were mostly my friends on the IBDP course. One of them is currently working in a Computer Science-related job and she also told us that she used to learn some coding when she was in university. It made me feel a bit inferior to her (well, I've always felt inferior to her ever since that one teacher in IB compared me to her, and she said something along the line that this other person was better than me because of one thing that I didn't have) since I did try this one online CS course, but I only finished it halfway and just deserted it, until recently.

Flash forward to Oct 2020, it has been more than a year since I last did the course. As I was scrolling around the new course structure, I found out that I couldn't just send my old Problem Sets especially Problem Set 0 because the version that I did for the course year 2018 used an sb2 file, but the current file uses sb3 instead. Furthermore, the course outline also looks different from what I remember it to be.

At that point, I felt that I should just re-do everything as if I've never done it before.

Today, I watched the introductory lecture and did Problem Set 0. I have to admit, Alhamdulillah, that I took a shorter time to complete it despite coming up with a new idea and not just replicating the old stuff that I did back in 2018. Not that I was very familiar with SCRATCH by MIT, but maybe because I knew what is already expected of me and how I should approach a problem.

Problem Set 0, Complete! :D

That's it for now! Pray for me so that I do finish this course! Ganbarimasu!


Friday 2 October 2020

Using SAMSUNG Notes for Drawing 2

After drawing a few images using SAMSUNG Notes on my tablet as recorded in the previous post, I decided to explore more of the functions available on the drawing mode. Here are some of the results:

Drawing 1: I wanted to try "shading" techniques with this drawing, except that I used the marker mode rather than the pencil mode. By adjusting the size of the marker tip, the results turned out great. The darker ones had lines drawn in four or directions, while the lighter ones have lesser lines. But for CĂ©leste's armour, I used the mixer/blender pencil, and it gives out the smooth surface as if I smudged a surface that I coloured using pencils.

Drawing 2: I coloured the people using "pencil colours", and I coloured on certain areas longer to make the shadows for darker areas. Then, I outlined them using marker pen. But for the backgrounds, I used crayon mode. The cool thing about the crayon is that the size can get really big, so it makes colouring the backgrounds much easier.

Drawing 3: Actually, this one is quite straightforward. I coloured the entire drawing canvas with black marker, and then using the eraser, I drew this picture. Pretty straightforward, right?

Drawing 4: I coloured the people using marker, but I didn't colour all the surfaces in one go. The lighter areas were left uncoloured, but I used the mixer/blender to blend the colours. As for the backgrounds, the top background was coloured using crayon, and then smoothed using the mixer/blender while the background on the lower part was coloured using the paintbrush mode.

There you have it, my explorations and experimentations. What kind of drawings will I do next?

Monday 31 August 2020

Using SAMSUNG Notes for Drawing

Aside from daydreaming, I like to draw. Especially now that I am on my semester break. I do admit that I need to prepare my research proposal for my Masters course, but I still am not sure if my chosen topic is a doable topic. Specifically, I am very concerned about the availability of data (ugh). 

To get my head out of this worry, I would draw something, or think of the story line and dialogues for Project Luna. Other times, I'd just draw things that I saw which I thought would be cute to draw.

Lately, I've been using my SAMSUNG Galaxy Tab S3's Notes to draw. I think it is a very convenient tool to use for drawing, for colouring as well. On top, we can choose what tools we want to use, such as pencil, paint brush or markers. Then we can customise the size of the tool. I'd always resize the marker to a larger size when colouring my drawings as it enables me to colour in a lot of spaces with just one swipe and this saves time.

There are many more features but I haven't tried them yet. Maybe will do in the future.

What I've been experimenting lately would be adding shadows to my drawings. I have very limited knowledge in shadowing, but I think I did well, referring to other pictures or drawings for guidance. Here are the results so far...

Claire Denise, the main character for my Project Luna. I actually hesitated to make her as muscular as this, but after browsing some images and encountering Korra from The Legend of Korra, I became more confident; "This is how I want Claire to be!"

Kiti curling into a curry puff. The stray cat Kiti has been spraying in our house frequently nowadays, and sometimes when he does, we would lecture him. He understands that we are angry at him when we lecture him, and he would curl himself and close his eyes. Today, he curled himself into a curry puff kinda shape. He was so cute that I just had to draw this.