Skip to content

Instantly share code, notes, and snippets.

View hannahstwinter's full-sized avatar

Hann Winter hannahstwinter

  • Rackspace
  • Richmond, VA
View GitHub Profile
@hannahstwinter
hannahstwinter / sum_of_multiples.rb
Last active December 20, 2015 13:49
Used to calculate the sum of all natural numbers below 'below', that are multiples of any number of numbers: '*multiples_of'.
class CrazyMath
def initialize(below, *multiple_of)
@below = below
@multiple_of = multiple_of
end
def sum_of_multiples
array_of_multiples
@multiples.uniq.inject(:+)
@hannahstwinter
hannahstwinter / largest_palindrome.rb
Last active December 20, 2015 13:49
Used to calculate the largest palindromic number that can be made from the product of 2 numbers, each being 'digits' digits long.
class Palindrome
def initialize(digits)
@digits = digits
end
def largest_palindrome
num_arr = build_numbers
decrement_zero = num_arr[0]
decrement = 0
@hannahstwinter
hannahstwinter / fizzbuzz.rb
Last active December 20, 2015 13:49
Flexible FizzBuzz. Comes with two separate helper methods methods, fizzbuzz_n_print and curse_thine_enemies (must be setup with a mailer of your choice). Initializes with three arguments (the numbers representing 'fizz' and 'buzz' as well as the cap for evaluation). Just for fun.
class FizzBuzz
def initialize(fizz, buzz, cap)
@fizz = fizz
@buzz = buzz
@cap = cap
end
def fizzbuzz_n_print
fizzbuzz_it