Your SlideShare is downloading. ×
0
Odin Ruby Study Group
Hello I am Brian
I will be you guide
@brianllamar
ilikerobot[at]gmail
Extras
Sign up for Odin G+ Community
Sign up for Ruby Newbie Group
- both will assist in helping
While you are at it Sign ...
Odin Project is open sourced
In Ruby Everything is an Object
Define Car Class
class Car
# code goes inside
end
create Car parts
class Car
def initialize # method
# part go here
end
end
Create car parts
class Car
def initialize # method
@engine = Engine.new
@wheels = 4.times.map { Wheel.new }
end
end
Let get Proceduaral (Law & Order)
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,...
class Multiples
def multi_pulls
# set range variable 1..1000
numbers = Array(1...1000) # inclusive range
multi_pulls = [] ...
sample_array = (20.downto(1)).to_a # create the array 1 to 20
least_common_denominator = sample_array.inject(:lcm) # find ...
Practice Practice Practice
New
Schedule
Discussion
Upcoming SlideShare
Loading in...5
×

Odin ruby week 1

59

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
59
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Odin ruby week 1"

  1. 1. Odin Ruby Study Group
  2. 2. Hello I am Brian I will be you guide @brianllamar ilikerobot[at]gmail
  3. 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. 4. Odin Project is open sourced
  5. 5. In Ruby Everything is an Object
  6. 6. Define Car Class class Car # code goes inside end
  7. 7. create Car parts class Car def initialize # method # part go here end end
  8. 8. Create car parts class Car def initialize # method @engine = Engine.new @wheels = 4.times.map { Wheel.new } end end
  9. 9. Let get Proceduaral (Law & Order)
  10. 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. 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. 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. 13. Practice Practice Practice
  14. 14. New Schedule
  15. 15. Discussion
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×