Learning to Code: Week 6 – Codecademy

6/15/16 – Continued

Read chapter 6 of Grokking Algorithms

  • Breadth-first Search
  • What are graphs
  • Directed graphs vs Undirected graphs
  • Queues
  • Queues (FIFO) vs Stack (LIFO)
  • Implementing the algorithm in Python
  • Topological sort
  • Trees


  • Website discovered: http://c.learncodethehardway.org/book/index.html (free resource)
    • He says: “LCTHW will not be for beginners, but for people who have at least read LPTHW or know one other programming language.”
    • Hopefully I can get something out of it regardless.
    • LCTHW Exercise 1: Dust Off That Compiler
  • Didn’t get much done today. Pretty bummed about it. 😕


  • Since I have the Javascript meetup coming up, I started on the Codecademy Javascript course just to mess around.
  • I don’t like to jump around too much though so I don’t think I’ll go too deep into it, only up until the workshop. CS50 is my main focus.
  • Is console.log same as the cs50 printf function?

CS50 walkthrough videos:

  • Sigma function
  • Swapping
  • Copying
  • Compare
  • Structs
  • Pointers
  • Coursera is changing platforms and getting rid of 400+ courses so I downloaded a few good ones before they are gone:
    • Algorithms Part I by Kevin Wayne and Robert Sedgewick (Princeton University)
    • Algorithms Part II by Kevin Wayne and Robert Sedgewick (Princeton University)
    • Compilers by Alex Aiken (Stanford University)
    • Introduction to Mathematical Thinking by Dr. Keith Devlin (Stanford University)


  • Finished entire Codecademy Javascript Unit #1 – INTRODUCTION TO JAVASCRIPT
    • Breezing through it since it’s all a refresher from CS50 just with different style/words.


Critical hits work a bit differently in this RPG. If you roll the maximum value on a die, you get to roll the die again and add both dice rolls to get your final score. Critical hits can stack indefinitely — a second max value means you get a third roll, and so on. With enough luck, any number of points is possible.

I am using CS50’s library as that is the only programming class I’m taking at the moment and am only on week 4. I am sure there is a way to simplify the probability formula as well.

Biggest hurdle was thinking about what the recursive case and base case would be. The twist is that there is always a chance if you roll the largest number on the die so (1/d) * (the next probability) and so on and so forth.

I am not so good with understanding how to use the data types so I chose double for everything since a lot of division was involved. Also I don’t know a good way to format the output. I don’t know how to put it into a nice grid or anything like that.

Also I should be dealing with memory allocation and clearing, but I only just learned how in CS50 and haven’t implemented it over there yet.

Coding in Real Life vs Coding in the Movies (I find this to be true)

Coding IRL


  • Read Chapters 4-8 in CODE book.
  • Part of chapter 7 in Grokking Alg: Dijkstra’s Algorithm
    • Seems simple in theory, but I am having a hard time wrapping my head around doing it step by step (fastest path/cheapest path through a weighted graph).
    • I’ll need to reread I think.


Week 4 – Section Videos

  • Hexadecimal (10min)
  • Pointers (Long but important – 30min)



Didn’t get anything in today! 😓


Was able to get up at 6:30 AM this morning for once.

Continuing JS course on Codecademy to prepare a little more for the workshop tomorrow evening:

  • An entire function ends in a ;
  • No mention of data types yet
  • DRY principle (Don’t Repeat Yourself) = Shawn mentioned this, but any time you find yourself typing the same thing, but modifying only one small part, you can probably just use a function.
  • Scope = global vs local variables

Finished Unit 2: Introduction to Functions in JS


Simple “Rock, Paper, Scissors” game here: https://gist.github.com/CraigRodrigues/067ffb27ae2cd18c1c9676286ea8502e