Looks good on paper…

Home » academia » MOOCs » CS50x — weeks 2 & 3

CS50x — weeks 2 & 3


I am now really rather behind, and may or may not manage to catch up, but I’m still enjoying doing CS50x on EdX. The website remains a bit clunky, and the videos huge to download, but I think these are simply the perils of MOOCs, and because I download the notes, problem set spec and most of the videos to watch at other times, it is not a daily problem to navigate.

The course runs online until 31 December 2014, so there is plenty of time for people who are interested to start now (or whenever, really).

Beware below some computer science jargon!

The second problem set required us to write two encryption programs: a Caesar cypher and a Vigenère cypher. The Caesar cypher was the simpler, and acted as a base for the second, but I struggled a bit with figuring out the ASCII math in order to loop around the alphabet from Z to A, rather than into non-alphabetic characters. Plus seg faults when I forgot I had to enter a command-line argument!

I tried to fight with this part of the pset for a fair long while because I didn’t watch the walkthrough until quite late on (again!). I think this is a good approach, though, despite the frustration it brings, as it is worth struggling on your own for a while, trying to reason things out, particularly as the 12-month long window for completing the course helps to focus the mind on mastery rather than getting things done as fast as possible. 

Once I’d figured out the ASCII math, the Caesar cypher was relatively simple, but the Vigenère cypher was harder to fix because I was getting genuine seg faults. The problem was relatively obvious — somewhere I was trying to access memory that wasn’t actually part of my array — but I had to spend a lot of time figuring out exactly where this was happening, as there was no error message to guide me. I got there in the end by removing the not-strictly-necessary (and not-quite-functioning) nested for loop. I did have a horrible feeling of ‘perhaps this is beyond me’, though, on Saturday night, which was not much fun. I’m glad I managed to wake up in a better mood!

What I was very conscious of with both of these programs was style. I had a habit of insisting on using not-strictly-necessary ‘if/else‘ structures where ‘if’ could really stand alone without the need to further indent the rest of the code within an ‘else’ structure. My formulae for the ASCII math was also a bit clunky, I think (and took me close to CS50’s informal limit of 80 characters per line). There was a balancing act being making the code ‘legible’ so that someone could understand how the formula worked and simplifying it mathematically. I would like to look again at the two programs after having some comments back on my code, but I’m not sure when that will be (or even whether the whole MOOC class will get comments from the teaching staff, given their commitments to the Harvard real-life students).

As I’m trying hard to complete the course as much in time with the real-life version as possible, I’m not looking at the ‘hacker’ versions of the psets yet, which are more challenging. I would like to find the time, perhaps next week, to take a look at these from weeks 1 and 2, whilst also getting started on pset3.

My posts on previous weeks are here: Week 0 & 1; Weeks 1 & 2.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: