Skip to content

Instantly share code, notes, and snippets.

@BooneTeam
BooneTeam / gist:5554773
Created May 10, 2013 14:32
Student Schema
https://github.com/BooneTeam/ar-student-schema.git
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@BooneTeam
BooneTeam / index.html
Last active December 17, 2015 15:59 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------
@BooneTeam
BooneTeam / factorial_recursion.rb
Created July 3, 2013 18:51
Recursive Factorial Solution
def factorial_recursion(n, factorial = 1)
return factorial if n == 1
factorial *= (n)
factorial(n-1, factorial)
end
puts factorial_recursion(5)
#Run it at CodePad.org
@BooneTeam
BooneTeam / gist:5922180
Last active December 19, 2015 07:59
Prime Factors Recursive
def primes(x, factors = [], y=2)
return factors if y > x
if x % y == 0
factors << y
x /= y
else
y +=1
end
primes(x,factors,y)
end
@BooneTeam
BooneTeam / largest_product.rb
Created July 9, 2013 00:26
largest product in a series computed recursively and iteratively
class LargestProduct
attr_accessor :series
def initialize(series)
@series = series
end
def split_series
series.split("").map {|num| num.to_i }
@BooneTeam
BooneTeam / binary.rb
Created July 9, 2013 01:04
binary search
# This will find the center_point
def binary_search(num, arr)
low = 0
high = arr.length - 1
while (low <= high)
i = ((low+high)/2).floor
if arr[i] < num
low = i+1
@BooneTeam
BooneTeam / benchmark_fib.rb
Created July 9, 2013 01:15
Benchmark Fibonacci iterative and recursive
require 'Benchmark'
def fibonacci_iterative(n)
return 0 if n == 0
vals = [0,1]
(n-1).times do
vals << vals[-1]+vals[-2]
end
vals.last
end
@BooneTeam
BooneTeam / arrays.rb
Created July 9, 2013 12:27
Creating my own enumerable methods in ruby
=begin
Array#each
calls a block for each item in an array
Array#map
calls a block for each item in an array and returns a new array based on this block
Array#inject
Takes an argument and calls a block for each item in an array. The argument value is manipulated