Skip to content

Instantly share code, notes, and snippets.

View andyweiss1982's full-sized avatar
πŸ‘¨β€πŸ«

Andy Weiss andyweiss1982

πŸ‘¨β€πŸ«
  • Restaurant Brands International
  • Miami, FL
  • LinkedIn in/andyweiss
View GitHub Profile
(1..100).each { |i|
if i % 3 == 0 and i % 5 !=0
i = "Fizz"
elsif i % 5 == 0 and i % 3 != 0
i = "Buzz"
elsif i % 3 == 0 and i % 5 == 0
i = "FizzBuzz"
end
def max_refactor (*rest)
rest.sort.last
end
def float_fixer (num = 0, *rest)
if num.is_a?(Float)
num = num.to_s.split(".")
d = (num[0]).to_i
c = num[1]
if c.to_i < 10
c = (c+"0").to_i
def bigger_num (num1, num2)
if num1 > num2
puts num1
elsif num2 > num1
puts num2
else
puts "equal"
end
end
# Add 2 to the number.
def add_two(number)
if number.respond_to? :+
if number.respond_to? :push
number.push 2
elsif number.is_a?(String)
number.to_f + 2
else
number + 2
end
@andyweiss1982
andyweiss1982 / tip.rb
Last active August 29, 2015 14:04
Tip calculator
puts "How much did the meal cost?"
inputok = false
until inputok == true do
mealprice = gets.chomp.to_f
if mealprice > 0
mealprice = (mealprice*1.20).round(2).to_s.split(".")
inputok = true
else
@andyweiss1982
andyweiss1982 / whichdoor.rb
Last active August 29, 2015 14:04
Door Game
#Defining all the possible outcomes
numbererror = "I don't understand what you said. You need to type 1, 2 or 3."
lettererror = "I didn't catch that. You need to type K for keep or T for trade."
door1 = "MILLION DOLLARS"
door2 = "DOLLAR BILL"
door3 = "WHOLE LOT OF NOTHING"
prizepic1 = "
XXXXXXXXXXXXXXXXXXFEDERAL RESERVE NOTEXXXXXXXXXXXXXXXXXXX
XXX XX THE UNITED STATES OF AMERICA XXX XX
XXXX XX ------- ------------ XXXX XX
@andyweiss1982
andyweiss1982 / Wyncode.rb
Created July 22, 2014 21:47
IRB Portfolio
puts "RUBY SYNTAX"
puts ""
puts "Question: Ruby Typing Practice"
puts ""
puts "You should practice typing Ruby code until it feels natural."
puts "You should be able to type Ruby code as fast as you can type English."
puts "Go through each slide in the lecture and type each line of code you find into irb."
puts "Code is always written in the Courier font. Do not copy-and-paste."
puts "There are traps in the slides that will get you into trouble if you do that."
puts "When you're done, just respond to this question with 'ok'."