This file contains hidden or 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
# # Sort the array from lowest to highest | |
def sort_Anderson(arr) | |
# arr.sort #initial code | |
flag =true | |
while flag | |
arr_before = arr.clone | |
arr = check_next(arr) | |
flag = false if arr_before == arr | |
end |
This file contains hidden or 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 user_input | |
puts "what do you have to say to Shakil(dog):" | |
gets.chomp | |
end | |
def shakil_behavior(user_input) | |
user_input = "treat" if user_input.include? "treat" | |
case user_input |
This file contains hidden or 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, baller, rent) | |
baller && (furnished || rent < 2100) | |
# if baller && (furnished || rent < 2100) | |
# return puts true | |
# else | |
# return puts false | |
# end | |
end |
This file contains hidden or 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 fizzBuzz(_start,_end) | |
_start.upto(_end) {|i| | |
puts "Fizz" if i%3 == 0 && i%5 != 0 | |
puts "Buzz" if i%3 != 0 && i%5 == 0 | |
puts "FizzBuzz" if i%3 == 0 && i%5 == 0 | |
puts i if i%3 != 0 && i%5 != 0 | |
} | |
end |
This file contains hidden or 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 | |
def maximum(arr = 0) | |
#arr.max #Initial code (lighthouse code) | |
max_value = arr[0] | |
max_value = 0 if arr[0] == nil #Avoid empty array, makes answer zero | |
arr.each do |i| | |
max_value = i if (max_value <= i) | |
end |
This file contains hidden or 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
vagrant [coding_ruby]> irb | |
2.1.3 :001 > quit | |
vagrant [coding_ruby]> pry | |
[1] pry(main)> def say_hi | |
[1] pry(main)* puts "input your name" | |
[1] pry(main)* name = gets.chomp | |
[1] pry(main)* puts "hi #{name}" | |
[1] pry(main)* end | |
=> :say_hi | |
[2] pry(main)> say_hi |
NewerOlder