This file contains hidden or 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
| require './hamming_test.rb' | |
| class Hamming | |
| def self.compute(first, second) | |
| distance = 0 | |
| index = 0 | |
| first = first.chars | |
| second = second.chars |
This file contains hidden or 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
| 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? "?" |
This file contains hidden or 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 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" |
This file contains hidden or 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
| santas = [] | |
| extra_people = [] | |
| open("secretsanta.txt").each do |row| | |
| stuff = row.chomp | |
| thing = stuff.split(" ") | |
| santas << thing.first | |
| extra_people << thing.first | |
| end |
This file contains hidden or 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
| 1.upto(100).each do |x| | |
| puts x = x + 1 | |
| end | |
| if 6 % 3 == 0 | |
| puts "Fizz" | |
| if 10 % 5 == 0 | |
| puts "Buzz" |
This file contains hidden or 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 Person | |
| attr_accessor :name, :house, :castle | |
| def initialize(name, house, castle) | |
| @name = name | |
| @house = house | |
| @castle = castle | |
| end | |
| end |
This file contains hidden or 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 Game | |
| attr_accessor :player_input, :computer | |
| def initialize | |
| @computer = %w(rock paper scissors).sample.upcase | |
| end | |
| def play selection | |
| @player_input = selection |
This file contains hidden or 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
| require 'csv' | |
| deliveries = [] | |
| CSV.foreach("./logs.csv", headers: true) do |row| | |
| deliveries << row.to_hash | |
| end | |
| #Fry - pilots Earth |
This file contains hidden or 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
| # 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] |
This file contains hidden or 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
| # 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 |
NewerOlder