Skip to content

Instantly share code, notes, and snippets.

@aguayma
aguayma / mario-a-wyncode.rb
Created January 13, 2015 23:08
My Favorite Questions So Far....
puts <<first
1 Push It, Push It Good
What’s the difference between these two Ruby expressions?
[1,2,3].push(1,2,3)
[1,2,3].push([1,2,3])
#You can push items into an array, and it will append the original array
#with the new data at the end.
1a The first results in [1,2,3,1,2,3] adding the (1,2,3) in order to the array
@aguayma
aguayma / tip_calculator
Created January 14, 2015 22:15
How was your meal?
puts "How much is the bill?"
bill = gets.to_f
puts "The bill is $#{bill}"
puts "How would you like to pay? Visa, Amex, Diners Club?"
pay = gets.chomp
@aguayma
aguayma / leisure_suit_larry
Created January 14, 2015 23:08
Leisure Suit Larry
puts "Hey Larry! That's your name right?"
you_Larry = gets.chomp
if "Yes".downcase
puts "I knew you were!! I would recognize that cheap suit anywhere"
else
puts "Listen here you dirty ba&^$^. You're Larry and theres nothing you can do about it!!"
end
puts <<END
@aguayma
aguayma / tip_calculator2
Created January 15, 2015 01:08
Wheres the beef?
puts "How much is the bill?"
bill = gets.to_f
puts "The bill is $#{bill}"
puts "How would you like to pay? Visa, Amex, Diners Club?"
pay = gets.chomp
@aguayma
aguayma / LSL_Game
Created January 15, 2015 01:10
LSL Game
puts "Hey Larry! That's your name right?"
case gets.chomp
when "yes".downcase
puts "I knew you were!! I would recognize that cheap suit anywhere"
else
puts "Listen here you dirty ba&^$^. You're Larry and theres nothing you can do about it!!"
end
puts <<END
@aguayma
aguayma / 2_2
Created January 15, 2015 22:57
Hey you can't do that here
# Add 2 to the number.
def add_two(number)
if number.respond_to? :+
if number.respond_to? :push
number.push 2
elsif number.respond_to? :squeeze
puts "Please enter a valid number!"
else
number + 2
end
@aguayma
aguayma / mad_max
Created January 16, 2015 14:54
Mad_max
def mad_max(a,b)
if (a.is_a? Fixnum) && (b.is_a? Fixnum)
puts [a,b].max
else
if a||b == String
puts "Please put a valid number"
end
end
end
def mad_max(a,b, *rest)
if (a.is_a? Numeric) && (b.is_a? Numeric)
puts [a,b].max
else
puts "Please put a valid number"
end
end
@aguayma
aguayma / fizzbuzz
Created January 19, 2015 16:08
Syntax
(1..100).each do |n|
case
when (n % 3 == 0) && (n % 5 == 0)
puts "FIZZBUZZ"
when n % 3 == 0
puts "Fizz"
when n % 5 == 0
puts "Buzz"
else
puts n
@aguayma
aguayma / quadV2
Created January 21, 2015 23:20
Help me Jesus
class Quadrilateral
attr_accessor :top, :bottom, :left, :right
def initialize(left, top, right, bottom)
@left = left
@top = top
@right = right
@bottom = bottom
end
#gets the perimeter of the quads