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
#COUNT LETTERS | |
def count_letters(sentence) | |
letters = {} | |
sentence = [sentence] | |
sentence.each do |words| | |
word = words.split('') | |
word.each do |letter| |
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
list = { | |
yvr: 'Vancouver', | |
yba: 'Banff', | |
yyz: 'Toronto', | |
yxx: 'Abbotsford', | |
ybw: 'Calgary', | |
} | |
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
# Save this file to your computer so you can run it | |
# via the command line (Terminal) like so: | |
# $ ruby shakil_the_dog.rb | |
# | |
# Your method should wait for user input, which corresponds | |
# to you saying something to your dog (named Shakil). | |
# You'll probably want to write other methods, but this | |
# encapsulates the core dog logic | |
def shakil_the_dog |
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)) | |
puts "YES" | |
return true | |
else | |
puts " NAH" | |
return false | |
end | |
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
def fizzbuzz1 | |
# | |
puts "Please put your range:" | |
#number1 = gets.chomp.to_i | |
first_num = gets.chomp.to_i | |
last_num = gets.chomp.to_i | |
n = (first_num..last_num) | |
array = n.sort | |
array.each do |fixnum| |
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
# Find the maximum | |
#Scan the array to compare integers and find the maximum | |
#within that array if there are objects inside the array | |
#otherwise set it to nil. | |
def maximum(arr) | |
#arr.max | |
#create the sort option | |
#comparing the actual number not the index using arr[i] | |
itswaps = true |
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
Fiorellas-MacBook-Pro:lighthouse LHL$ irb | |
irb(main):001:0> def say_hi(name) | |
irb(main):002:1> "Hello, #{name}" | |
irb(main):003:1> end | |
=> nil | |
irb(main):004:0> say_hi("Meow") | |
=> "Hello, Meow" | |
irb(main):005:0> say_hi() | |
ArgumentError: wrong number of arguments (0 for 1) | |
from (irb):1:in `say_hi' |
NewerOlder