Skip to content

Instantly share code, notes, and snippets.

@arn-e
arn-e / toc.rb
Created October 11, 2012 03:11
toc
#Getting Started,1
#Numbers,9
#Letters,13
#Variables and Assignment,21
#Mixing It Up,25
#More About Methods,33
require 'csv'
class TableOfContents
@arn-e
arn-e / gist:3870109
Created October 11, 2012 04:08
Numbers_in_words
We couldn’t find that file to show.
@arn-e
arn-e / binary_search.rb
Created October 11, 2012 20:13
binary search
#binary search
def binary_search(item,array,min = 0,max = array.length, half = (min + max) / 2)
return min if item == array[min]
return -1 if (item < array[0] || item > array[array.length-1]) || (min == max - 1)
item < array[half] ? binary_search(item,array,min,half) : binary_search(item,array,half,array.length)
end
test_array = (1..15).to_a
puts binary_search(13,test_array) == 12
@arn-e
arn-e / numbers_to_words.rb
Created October 13, 2012 00:08
numbers_to_words
class NumbersToWords
@@words = { 1=> "one",
2=>"two",
3=>"three",
4=>"four",
5=>"five",
6=>"six",
7=>"seven",
8=>"eight",
@arn-e
arn-e / orange_tree.rb
Created October 15, 2012 03:29
orange_tree
MAX_AGE = 120
class OrangeTree
def initialize
@height_total_inches = 0
@age = 0
@orange_count = 0
end
@arn-e
arn-e / hospital.rb
Created October 15, 2012 19:55
hospital_framework
class Hospital
#name, location, number of employees
#number of patients
#login, show interface
#wait for user input
#present login menu
#accept credentials
#credentials are associated on a employee level
end
@arn-e
arn-e / todo1.rb
Created October 16, 2012 05:11
todo list revision 1
#questions :
#1. how to check if file exists? Better way than opening with 'append' (+)?
#2. how to write to middle of file? does the entire file need to be re-written from the contents in memory?
class TodoList
def initialize()
@file_name = "todo_file.txt"
@file = File.new(@file_name,'r+')
@todo_list = {}
require 'securerandom'
class Hospital
attr_accessor :name,:location
def initialize
@name = "Dev Bootcamp Asylum?"
@location = "717 California St"
@employee_count = 7
@arn-e
arn-e / administrator.rb
Created October 17, 2012 03:36
hospital
require './user'
require './employee'
class Administrator < Employee
def initialize(name)
super
@record_access = :admin
@title = "Administrator"
@password = default_password
end
@arn-e
arn-e / rspec_binary_search.rb
Created October 18, 2012 17:59 — forked from dbc-challenges/rspec_binary_search.rb
Rspec Binary Search
require './binary_search'
# your rspec code here!