in Prose

cs50x – Week 1

Hang tight kids, because it’s time to do some real coding.

Things have really stepped up a notch this week. No more mucking trying to convince a cat to do something original.

Screen Shot 2016-08-24 at 23.48.04

Yup. I did rock-paper-scissors. I’m not proud of myself.

Nope, it’s time to get out that blinking command line prompt and get your hacking fingers on. Where will we start? Coding a cyber-bomb? Destroying nuclear enrichment plants? Developing tools to hunt down trolls and ban them from anything more advanced than an abacus?

Screen Shot 2016-08-24 at 23.50.56

Seriously, can we make that a priority.

Not exactly. This week the problem sets require us to:

  • calculate how many bottles of water we use in an x-minute long shower, where the user inputs the number of minutes.
    • The calculation had to be in imperial or you failed the tests. You know who else uses imperial? Burma and Liberia. That’s it.
  • print a Mario-style half-pyramid made of hashes with a user-inputted height.
    • This problem haunted me like the ghost of Christmas future because
      • a) computers, like the Spirit, do not talk. Despite, or perhaps because of this, they are terrifying and unknowable
      • b) it was very late at night and I may have been drunk/asleep/vividly hallucinating/some combination of the above
  • programme a ‘greedy’ algorithm. A greedy algorithm is one that returns as few coins to shoppers as possible (while returning the correct change), ensuring you don’t leave weighed down by useless copper and shopkeepers get to keep them.
    • If you’re wondering what they do with them, it’s probably this:
tumblr_mslx9kwdn11rkumvuo1_400

Don’t come at me with “That’s not how physics works”. It’s a duck wearing a bathing costume and pince-nez. I knew going in that this wasn’t going to be a historical documentary.

The code has been in C, also known as the grandaddy of code.1 It’s been a pretty sharp learning curve for me, because C requires a compiler. The only other language I know – Python – does not. Compiling code means converting it from the pseudo-English it’s written in to binary. It must be compiled before it can be fed to the machine, which means making small alterations suddenly becomes exponentially more annoying because you have to recompile the thing. With only a few lines of code this takes seconds, but I imagine something big would take ages. What would you do with that time?

Trying to get kids into coding? This. This is all you need.

I’ve got to say I’m buzzing about this course. There’s loads of material that I haven’t covered, and I’m actually starting to consider that the US university experience might not be everything Hollywood has told me. I’d still like to try it, though of course at this point I’m probably getting too Steve Buscemi for frat parties.

giphy

Also, being English, I would indeed say “How do you do?”

Final words: I’m hopeful I’ve dragged a colleague into this journey; someone else on the course has reached out via Twitter, and I’m reminded that we can sometimes do very cool things with the web. Like this 7-minute aca-mash-up2 of Hamilton.


1 By me.
2 If you came here hoping for an apology you’re going to be disappointed.

Write a Comment

Comment