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 benchmark | |
# Your benchmarking code goes here. | |
start_time = Time.now | |
yield | |
end_time = Time.now | |
running_time = end_time - start_time | |
end | |
# Be careful, pasting this into IRB will take a long time to print. | |
# It's a loooong string. :) |
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 count_letters(user_input) | |
counted = {} | |
characters = user_input.split("") | |
for char in characters | |
if char == " " | |
next | |
elsif counted.has_key? char |
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 sum(list) | |
sum = 0 | |
list.each do |num| | |
sum += num | |
end | |
sum | |
end | |
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
# must be baller and either furnished or rent cheaper than 2100 | |
def rent?(furnished, rent, baller) | |
#if baller && furnished || rent < 2100 | |
if baller && (furnished || rent < 2100) | |
return true | |
else | |
return false | |
end | |
end |
NewerOlder