< More Posts

CS50: Week 2

Published 09 July 2020 at Yours, Kewbish. 1064 words. Subscribe via RSS.

Also published on Dev.to.


And now, our third week of CS50!1 This week, we went over arrays, but also spent a lot of time on CLI / terminal things, and debugging tools used by CS50. I’m starting to get more familiar with the CS50 system, and how I can do problem sets and debug on my local system, instead of the cloud IDE. (Again, remember how I hate it?) This was our introduction to proper command line arguments, and how to use function arguments in main too.


Some of this references the video and the problem set, so you might want to check out the notes here.

Problem Sets

Last week, I mentioned how I prefer doing both of the ‘more and less’ problems in the problem set for a week, noting that the ‘more’ usually builds off the ‘less’. This week was a great example of that.

Readability doesn’t really count, that was more an introduction to looping (? I didn’t use an array at all so I’m not sure what they’re on about), but Caesar and Substitution were super fun. Caesar is, what you might think, a caesar cipher implementation. Substitution implements a simple substitution cipher. While working through Caesar, I found a bunch of information about character codes and validating command line arguments, as well as working with aforementioned character codes and CLI arguments. For example, I was super confused about a Segmentation Fault that was thrown while attempting Caesar because I’d forgotten to check that the argument actually existed. As well, I learned that you could :gasp: subtract characters, instead of just using the character code. These two morsels of information were super helpful in solving Substitution. Both ciphers deal with some sort of ‘distance from something else and then add key’ algorithm, and I found that figuring Caesar out let me speedrun through Substitution so much more quickly.

Setting up CS50 locally

I’ve finally finished setting up CS50’s development tools on my own system - since last week, I’ve been trying to tweak a couple commands and things to make everything just work.

Here’s a small checklist of things that I’d recommend setting up, and some caveats.

cs50make() { 
    # command copied from running make in ide.cs50.io
    # replace the [whatever].c with "$1".c, and same for the output
export -f cs50make

which will let you run cs50make in terminal and run the equivalent make command

See - it’s not that hard. Even easier on Linux, probably. And now, you can CS50 in VSCode, and have beautiful syntax highlighting and snippets. God, I hate that IDE.


Apologized for the extremely strange blogging schedule - expect another post on Sunday as well. I’d finished a couple of problem sets and weeks in one week, while my writing schedule was supposed to run at one post per week. I’ve had to spend a bunch of time writing, so please appreciate me-

I’ve been working on some random scripts - nothing on GitHub, just little automation things. Been doing a little maintenance on diveintoht.ml as well. Hopefully I’ll start a bigger project soon, looking forward to the final project of CS50!

  1. Undoubtedly one of the more difficult weeks. ↩︎

- Yours, Kewbish

< More Posts