Odin ruby week 1
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
69
On Slideshare
69
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Odin Ruby Study Group
  • 2. Hello I am Brian I will be you guide @brianllamar ilikerobot[at]gmail
  • 3. Extras Sign up for Odin G+ Community Sign up for Ruby Newbie Group - both will assist in helping While you are at it Sign up for the Ruby Community.
  • 4. Odin Project is open sourced
  • 5. In Ruby Everything is an Object
  • 6. Define Car Class class Car # code goes inside end
  • 7. create Car parts class Car def initialize # method # part go here end end
  • 8. Create car parts class Car def initialize # method @engine = Engine.new @wheels = 4.times.map { Wheel.new } end end
  • 9. Let get Proceduaral (Law & Order)
  • 10. My approach is always different # # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # # Find the sum of all the multiples of 3 or 5 below 1000. # Pseudo # set range 1..1000 # set the if statment to find the multiples of 3 and 5 # use if statement to add nums divisible by 3 and 5 to be added to a new_range array. # create method that adds the new_range numbers to create a sum. # call the Multiple class using the muli_pulls method and sum_of_multiples method
  • 11. class Multiples def multi_pulls # set range variable 1..1000 numbers = Array(1...1000) # inclusive range multi_pulls = [] # create a new array for i in numbers # loop that runs through every number in the array if i % 3 == 0 || i % 5 == 0 # finds only numbers in array that are multiples of 3 and 5 multi_pulls << i # add those multiples to the new array end end multi_pulls # puts final multiple array end def sum_of_multiples(multi_pulls) # method to find the sum of the multipes array sum = 0 # create sum variable multi_pulls.each {|i| sum += i } # formula to take each number in array and add to sum variable, which creates the sum of multiples. puts sum # returns the sum end end m = Multiples.new # create a new class m.sum_of_multiples(m.multi_pulls) # calls the sum of the multiples
  • 12. sample_array = (20.downto(1)).to_a # create the array 1 to 20 least_common_denominator = sample_array.inject(:lcm) # find the least common denominator using using the lcm method between each integer in the array puts least_common_denominator
  • 13. Practice Practice Practice
  • 14. New Schedule
  • 15. Discussion