Skip to content

Instantly share code, notes, and snippets.

View philcallister's full-sized avatar

Phil Callister philcallister

  • Amazon Web Services (AWS)
  • Minneapolis, MN
  • 22:15 (UTC -06:00)
  • LinkedIn in/philcallister
View GitHub Profile
@philcallister
philcallister / mult_table.rb
Last active August 29, 2015 14:03
Multiplication Table
def mult_table(num, spaces)
max_space = (num * num).to_s.length + spaces
rows = []
(1..num).each do |row|
rows << (1..num).inject('') { |r,col| r += sprintf("%#{max_space}d", row * col) }
end
rows
end
mult_table(12, 2).each { |row| puts row }
@philcallister
philcallister / fizz_buzz.rb
Created June 25, 2014 18:09
A little too much fun with FizzBuzz
module FunFizzBuzz
class ModResult
include Comparable
attr_accessor :mod, :result_proc
def initialize(mod, result_proc)
self.mod = mod
self.result_proc = result_proc
end