Skip to content

Instantly share code, notes, and snippets.

@Ebonkuab
Ebonkuab / Benchmark.rb
Created January 7, 2016 19:21
code for getting how long it takes to run a programme written in Ruby using Yield keyword and blocks . (LIGHTHOUSE WEB DEV BOOTCAMP0
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. :)
@Ebonkuab
Ebonkuab / counting characters.rb
Created January 6, 2016 23:44
Ruby code for counting the number of characters in a string without counting space (LIGHTHOUSE LABS DEV BOOTCAMP)
def count_letters(user_input)
counted = {}
characters = user_input.split("")
for char in characters
if char == " "
next
elsif counted.has_key? char
@Ebonkuab
Ebonkuab / Debugging Code.RB
Created January 6, 2016 20:58
code decoded during the debugging excercise in Lighthouse Labs
def sum(list)
sum = 0
list.each do |num|
sum += num
end
sum
end
@Ebonkuab
Ebonkuab / renter.rb
Created January 6, 2016 00:55
an exercise for checking if the bolean operation is correct for the problem being solved
# 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