This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Describe | |
# Contianer- A container is is simply a place to contain a collection of other objects | |
# They are used for storing objects in a specific way under set rules. | |
# ------------ | |
# 2. Implement a container with all even numbers from 1..100 | |
def container(array) | |
ray = Array.new | |
array.each do |x| | |
if x % 2 == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choose_team(n, k) | |
return n if k == 1 | |
return 0 if n == 0 | |
choose_team(n-1, k-1) + choose_team(n-1,k) | |
end | |
puts choose_team(6,3) == 20 | |
puts choose_team(6,2) == 15 | |
puts choose_team(24,4) == 10626 |
NewerOlder