Skip to content

Instantly share code, notes, and snippets.

View zezantam's full-sized avatar

Zezan Tam zezantam

View GitHub Profile
@zezantam
zezantam / RomanNumerals.rb
Last active December 26, 2015 06:59
Roman Numerals Challenge from Dev Bootcamp
def classic_roman(int)
# initialise variable
num = int
num = num.to_f
output = []
# initialise keys
numeral_to_value = {
1 => "I",
@zezantam
zezantam / PowerOfEnumerables.rb
Created October 23, 2013 06:00
Power of Enumerables Exercise
# TODO: Print the elements at indices 1, 3, 5, 7, etc. on separate lines.
# You should make use of Enumerable#each_with_index
def print_odd_indexed_integers(array)
array.each_with_index { |obj, i|
if i % 2 == 1
puts obj
end
}
end
@zezantam
zezantam / NumbersInWords.rb
Created October 23, 2013 08:20
Numbers in Words Exercise
def in_words(int)
#define "in_words_3dig" batching function
#can take any 3 digit number and return the english words
def in_words_3dig(num)
#intiialise keys
singles = {
1 => "one",
2 => "two",
@zezantam
zezantam / boggle_board.rb
Created October 24, 2013 09:19
Boggle 1 Basic Board Generation Challenge
class BoggleBoard
def initialize
@board = ["","","","","","","","","","","","","","","",""]
end
def shake!
dice = %w{
AAEEGN
@zezantam
zezantam / SudokuSolverSimple.rb
Created October 25, 2013 01:24
Sudoku Solver: simple (no guessing)
class Sudoku
def initialize(board_string)
@board_string = board_string
@board_array = board_string.to_s.split("").map { |e| e.to_i }
end
def find_coords(num)
# gives (row, column, box), counting up from 0 up to 8
row = (num.to_f / 9).floor
col = num % 9
@zezantam
zezantam / serialization.rb
Created October 28, 2013 06:50
CSV In and Out exercise
require 'csv'
require 'date'
class Person
attr_reader :first_name, :last_name, :email, :phone, :created_at
def initialize(id, first_name, last_name, email, phone, created_at)
@id = id
@first_name = first_name

Keybase proof

I hereby claim:

  • I am zezantam on github.
  • I am zt (https://keybase.io/zt) on keybase.
  • I have a public key whose fingerprint is 8E86 6703 5E44 C858 BD91 22F2 78CC 1B0A 028C BC79

To claim this, I am signing this object: