@gSchool Week 5

Five weeks have come and gone at gSchool. I don’t know whether to lament the passage of time or to celebrate being one week closer to graduation. There’s emotional turmoil from knowing so little about programming and thus feeling a sense of underperformance. But I celebrate the victories as patterns come together in my mind and concepts become a part of a coding frame of reference. Coding is still elusive but I can sense its pattern under the surface and think (and hope!) to see larger results soon from all my hard work.

‘Learning styles’ has been a topic of conversation this week in class. The teachers have worked hard at adapting lesson styling to meet the needs of our diverse class of 26 students, providing opportunities to support learning styles in varying degrees of application. For me, I have loved learning when it has involved the whole class working together in a noisy collaboration while one student types and asks for input. The pace allows for ‘aha’ moments of understanding that can sometimes be missed when coding at a faster speed. Other students feel emotionally jolted by this same style and find it highly disconcerting and off-putting. The challenge has been on the teachers and students to find a way to bridge existing gaps so that no one feels left out or left behind.

With all the new classroom material to be learned, I wasn’t making much time for actual coding, so I’ve begun focusing on exercisms (and other coding problems). The plan is to get through at least five iterations of exercisms per week. This is an exercism I completed today that finds the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum:

class Squares
  def initialize(index) # index = max number in range
    @range = Range.new(1, index)
  end

  def square_of_sums
    sum = @range.reduce do |sum, index|
      sum + index
    end
    sum * sum
  end

  def sum_of_squares
    @range
    .map { |index| index * index }
    .reduce do |sum, index|
      sum + index
    end
  end

  def difference
    square_of_sums - sum_of_squares
  end
end

I found the ‘reduce’ method in ruby-doc and am still working to solidify its meaning and usage. The class instructors are vigilant about giving feedback, so my next code iteration will involve assigning the squares to an intermediate variable to make it easier to read. It helped when I started considering exercism code like Playdough… pliable, ever-changing and mutating. Now, I can see the value of posting code and asking for feedback to really solidify an understanding of how the code works. With that in mind, please feel free to post any suggestions for a future iteration.

Advertisements
This entry was posted in Computer Languages, Ruby and tagged , , , , , , , , , , . Bookmark the permalink.

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