Skip to content

Instantly share code, notes, and snippets.

@JWade34
JWade34 / day-12hw.rb
Created January 22, 2015 15:32
day-12hw.rb
require './hamming_test.rb'
class Hamming
def self.compute(first, second)
distance = 0
index = 0
first = first.chars
second = second.chars
@JWade34
JWade34 / day-11hw.rb
Created January 21, 2015 03:55
day-11hw
require_relative 'bob_test.rb'
class Bob
def hey(remark)
if remark.strip.empty?
"Fine. Be that way!"
elsif remark == remark.upcase && remark.downcase != remark
"Whoa, chill out!"
elsif remark.end_with? "?"
@JWade34
JWade34 / week-2lab.rb
Created January 20, 2015 06:24
week 2 lab - blackjack
class Card
attr_accessor :value, :suit, :name
def initialize(suit, name)
@suit = suit
@name = name
if ["King", "Queen", "Jack"].include? name
@value = 10
elsif name == "Ace"
santas = []
extra_people = []
open("secretsanta.txt").each do |row|
stuff = row.chomp
thing = stuff.split(" ")
santas << thing.first
extra_people << thing.first
end
1.upto(100).each do |x|
puts x = x + 1
end
if 6 % 3 == 0
puts "Fizz"
if 10 % 5 == 0
puts "Buzz"
class Person
attr_accessor :name, :house, :castle
def initialize(name, house, castle)
@name = name
@house = house
@castle = castle
end
end
class Game
attr_accessor :player_input, :computer
def initialize
@computer = %w(rock paper scissors).sample.upcase
end
def play selection
@player_input = selection
@JWade34
JWade34 / week-1lab.rb
Created January 11, 2015 20:56
week 1 lab
require 'csv'
deliveries = []
CSV.foreach("./logs.csv", headers: true) do |row|
deliveries << row.to_hash
end
#Fry - pilots Earth
# LAAAAAAAAAB
# get into array//// use array method
# bonus- class def instead of hash
open("planet_express_logs.txt").each do |line|
string_data = line.chomp
items = string_data.split(",")
planet = items[0]
what_got_shipped = items[1]
number_of_crates = items[2]
@JWade34
JWade34 / day-3
Last active August 29, 2015 14:13
# Assignment
#
# Robot
#
# Define a Robot class
# A robot has a name
# A robot should have a method called say_hi and it should return "Hi!"
# A robot should have a method called say_name and it should return
# "My name is X" where X is the robot's name