Pre-course week 2 – Ruby in the rough

Chris Pine – please would you kindly return my cosy rug and slip it back beneath my tootsies?

Yes, week two of Makers Academy pre-course may be over but the scars will stick with me for a while yet. And it all boils down to one man: Chris. Bloody. Pine:

Untitled

No. Not that Chris Pine. No man with such designer-stubble artistry and smouldering smize skills would ever cause me such pain. No, I mean Chris Pine, author of Learn to Program and chief destroyer of dreams.

Clearly we had all taken the bait – we’d happily let ourselves be lured into a false sense of security after completing the week one challenge. I was on top of the world. Commanding and committing and gitting all over the shop. Hell, milestones were a-toppling! That is, until Chris Pine came strutting along, all up in my grill like: you know nuthin’.

Before interviewing for MA, we all had to complete the first eight chapters of Learn to Program. There were a couple of exercise that made you stop and think, but in general it was a relaxed introduction to all things Ruby (the programming language we’ll be focusing on at Makers). Our challenge this week was to finish the book and turns out, oh so completely by chance of course, that things significantly ramp up right about the time chapter nine commences….

Hmm, I see what you did there Makers. Very schneaky.

That being said, I did make it through. Only once did I nearly erase all my treasured photographs. And only once did I corrupt all Photos app files. That really ain’t bad considering… right?

Ok, that IS quite bad. But I did some good things too. Positive stuff I managed included writing a hilariously primitive sorting method (kind of a right of passage for any newbie coder). My logic was:

  • Take and set aside the first item of your unsorted list and call it ‘smallest’
  • Take a look at the next item in the array:
    • If it’s smaller than the first, replace our incorrect ‘smallest’ with this item and bring back our first item
    • If it’s bigger, leave it alone
  • Repeat this comparison for all other items in array, until we have really found and set aside our smallest
  • Repeat this whole faffy shebang recursively to locate next smallest… and next smallest… and next smallest…

Feeling pretty damn pleased with myself that I’d managed to come up with such a sick and SLICK solution (who needs array.sort, huh?) I scrolled down to check out Chris Pine’s suggested solution. It’s so gonna be identical to mine, right? There is literally no point in me checking this.

Screen Shot 2016-07-31 at 15.25.18

Oh hot dayum that’s good.

Ok, so I’m not at this level just yet. But it will come.. hopefully. And anyway, with my new-found knowledge of classes, blocks and procs I spawned a virtual baby dragon that breathes fire, poops and tells me I’m doing just fine.

One thought on “Pre-course week 2 – Ruby in the rough

Leave a comment