Skip to content

Instantly share code, notes, and snippets.

def binary_search x, low = 0, high = -1
#-- Assume that a is already sorted
a = [3, 5, 7, 8, 10, 11, 14, 15, 26, 33, 34, 36, 39, 40, 41, 44, 45, 48, 49]
high = a.length - 1 if high == -1
midpoint = (high + low) / 2
if low == midpoint
def gcd ab, cd
return ab if cd == 0
r = ab % cd
gcd cd, r
end
end_value = 120
#-- Without using mod
b = Array(2..end_value)
primes = Array(2..end_value)
limit = Math.sqrt end_value
b.each do |z|
break if z >= limit
primes.each do |i|
end_value = 120
#-- Using mod
a = Array(2..end_value)
limit = Math.sqrt end_value
a.each do |x|
a.delete_if do |y|
next if y <= x
require 'gruff'
require 'csv'
ndx = []
tv_data = []
radio_data = []
newspaper_data = []
sales_data = []
CSV.foreach('../data/Advertising.csv', :headers => true) do |row|
# encoding: utf-8
require 'spec_helper'
describe "Test JSON response" do
before :all do
host = http://localhost:3000
@url = "api/v1/foobar"
headers = {
puts "Hello, world!"