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
# create an Array of 4 shoes | |
shoes = ["flip flops", "cowboy boots", "galoshes", "clogs" ] | |
# iterate through your Array using each and {}'s | |
# and show a list of your shoes | |
shoes.each { |s| puts s } | |
# create an Array of 4 outfits using Array.new |
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
# create an Array of 4 shoes | |
# iterate through your Array using each and {}'s | |
# and show a list of your shoes | |
# create an Array of 4 outfits using Array.new |
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
# ,o888888o. 8 8888 88 8 8888 8888888888',8888' | |
# . 8888 `88. 8 8888 88 8 8888 ,8',8888' | |
# ,8 8888 `8b 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8b 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 88 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8. 88 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8,8P 8 8888 88 8 8888 ,8',8888' | |
# `8 8888 ;8P ` 8888 ,8P 8 8888 ,8',8888' | |
# ` 8888 ,88'8. 8888 ,d8P 8 8888 ,8',8888' |
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
# ,o888888o. 8 8888 88 8 8888 8888888888',8888' | |
# . 8888 `88. 8 8888 88 8 8888 ,8',8888' | |
# ,8 8888 `8b 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8b 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 88 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8. 88 8 8888 88 8 8888 ,8',8888' | |
# 88 8888 `8,8P 8 8888 88 8 8888 ,8',8888' | |
# `8 8888 ;8P ` 8888 ,8P 8 8888 ,8',8888' | |
# ` 8888 ,88'8. 8888 ,d8P 8 8888 ,8',8888' |
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
# in irb, evaluate the following: | |
4 < 5 | |
4 == 5 # note the == is different from = | |
4 != 5 | |
1 <= 2 | |
0 > 1 | |
1 > 1 | |
1 >= 1 |
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
# Euler problem #1: 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. | |
def find_multiples num | |
multiples = Array.new | |
(1...num).each do |i| | |
if( (i % 3 == 0) || (i % 5 == 0) ) | |
multiples << i | |
end |
NewerOlder