This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deaf_grandma | |
returns = 0 | |
until returns == 2 | |
print "Say something to grandma: " | |
response = gets.chomp | |
if response.empty? | |
returns += 1 | |
elsif response.match(/[A-Z]/) | |
puts "NO, NOT SINCE 1938!" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_and_sort(array) | |
output_string = "" | |
array = array.map! {|str| str.to_s } | |
array.each do |element| | |
output_string = output_string + " " + element | |
end | |
puts output_string | |
array.sort | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_and_sort(array) | |
output_string = "" | |
array.map!(&:to_s).each do |element| | |
output_string = output_string + " " + element | |
end | |
puts output_string | |
array.sort | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def birthday_timestamp(date) | |
date = date.split('/') | |
month, day, year = date.pop(3) | |
birthday = Time.mktime(year, month, day) | |
time_now = Time.now | |
years = time_now.year - birthday.year | |
months = time_now.month - birthday.month | |
days = time_now.day - birthday.day | |
puts "#{years} years #{-months} months #{-days} day old" if days < 2 | |
puts "#{years} years #{months} months #{days} days old" if days > 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hashed_table | |
hashed_data_table = Array.new(4) | |
hashed_data_table[0] = ["Number", "Name", "Position", "Points per Game"] | |
hashed_data_table[1] = ["12", "Joe Schmo", "Center", "[14, 32, 7, 0, 23]"] | |
hashed_data_table[2] = ["9", "Ms. Buckets", "Point Guard", "[19, 0, 11, 22, 0]"] | |
hashed_data_table[3] = ["31", "Harvey Kay", "Shooting Guard", "[0, 30, 16, 0, 25]"] | |
hashed_data_table[4] = ["18", "Sally Talls", "Power Forward", "[18, 29, 26, 31, 19]"] | |
hashed_data_table[5] = ["22", "MK DiBoux", "Small Forward", "[11, 0, 23, 17, 0]"] | |
index = 1 | |
player_info = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(number, random_numbers) | |
middle = random_numbers.length / 2 | |
until random_numbers[middle] == number | |
if random_numbers[middle] < number | |
middle += random_numbers[middle..-1].length / 2 | |
end | |
if random_numbers[middle] > number | |
middle -= random_numbers[0..middle].length / 2 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BankAccount | |
def initialize(customer_name, type, acct_number) | |
@customer_name = customer_name | |
@type = type | |
@acct_number = acct_number | |
end | |
def customer_name=(customer_name) | |
@customer_name = customer_name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Todo | |
def initialize(file_name) | |
@file_name = file_name | |
@tasks = [] | |
load_file | |
end | |
def load_file | |
@task_file = File.read(@file_name) | |
@task_file.each_line { |line| @tasks << $1.strip if line =~ /^\d+. (.*)/ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ --> | |
<!-- Active URL: http://socrates.devbootcamp.com/sql.html --> | |
<sql> | |
<datatypes db="mysql"> | |
<group label="Numeric" color="rgb(238,238,170)"> | |
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/> | |
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/> | |
<type label="Single precision" length="0" sql="FLOAT" quote=""/> | |
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/> |