Skip to content

Instantly share code, notes, and snippets.

def leap_year?(year)
if (year % 4 == 0)
return true
elsif (!(year % 400 == 0) and (year % 100 == 0 and year % 4 == 0))
return false
elsif ((year % 100 == 0 and year % 400 == 0) and !(year % 4 == 0))
return true
end
end
def welcome(string)
if (string =~ /CA(.*)/ )
puts "Welcome to California"
else
puts "You should move to California"
end
end
def welcome(string)
if (string.match("CA"))
puts "Welcome to California"
else
puts "You should move to California"
end
end
def leap_year?(year)
if year % 4 == 0
puts true
elsif year % 100 == 0
puts false
elsif year % 100 == 0 && year % 400 == 0
puts true
elsif year % 4 == 0 && year % 100 == 0 && !(year % 400 == 0)
puts false
# test to see if valid triangle
def valid_triangle?(a, b, c)
if ((a == 0 or b == 0 or c == 0) or (a == nil or b == nil or c == nil))
return false
end
if a + b > c
return true
def super_fizzbuzz(array)
array.each do |w|
if w % 15 == 0
puts "FizzBuzz"
elsif w % 3 == 0
puts "Fizz"
elsif w % 5 == 0
puts "Buzz"
else
def has_ssn?(string)
if string =~ /\d{3}\W\d{2}\W\d{4}/
true
elsif string =~ /\d{9}/
true
else
false
end
end
@stomatocode
stomatocode / vehicle.rb
Last active December 18, 2015 09:19 — forked from aespaldi/vehicle.rb
class Vehicle
def powerplant(args)
@engine
@transmission
@drivetrain
end
def chassis(args)
def factorial_iterative(number)
until number == 1
number *= number - 1
number -= 1
p number
end
fib_num
class Die
attr_reader :dice, :top
@@dice = [['A','A','E','E','G','N'],
['E','L','R','T','T','Y'],
['A','O','O','T','T','W'],
['A','B','B','J','O','O'],
['E','H','R','T','V','W'],
['C','I','M','O','T','U'],