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
    
  
  
    
  | def mean(*numbers) | |
| sum = numbers.inject(:+) | |
| return sum / numbers.length | |
| end | |
| # This will throw an error. Change this line so that it works. | |
| sample_avg = mean(5, 3, 6, 10) | 
  
    
      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 Birthday | |
| def initalize | |
| @days = 0 | |
| @months = 0 | |
| end | |
| def days_in_year(year) | |
| leap_year?(year) ? 366 : 365 | |
| 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 RomanNumerals | |
| def initialize | |
| @reference = {"1"=> "I", "5"=> "V", "10" => "X", "50"=> "L", "100" => "C", "500"=> "D", "1000"=> "M", | |
| "4"=> "IV", "9"=>"IX","40" => "XL", "90" => "XC", "400"=> "CD", "900" => "CM"} | |
| end | |
| def to_roman(number,long_string = '') | |
| @reference.keys.map{|i| i.to_i}.sort.reverse.each do |i| | |
| count,number = difference(number,i.to_i) | 
  
    
      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
    
  
  
    
  | # Solution for Challenge: Deaf Grandma. Started 2012-10-01T22:56:30+00:00 | |
| class DeafGrandma | |
| def echo_grandma | |
| while (a = gets.chomp) != "" | |
| (a == a.downcase) ? (puts "HUH?! SPEAK UP, SONNY!") : (puts "NO, NOT SINCE 1938!") | |
| end | |
| 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 Student | |
| def height(height) | |
| @height = height | |
| end | |
| def hair_color(hair) | |
| @hair_color = hair | |
| end | |
| def shoe_size(dog) | 
  
    
      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
    
  
  
    
  | # Put your answers here! | 
  
    
      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 'pry' | |
| class BowlingGame | |
| attr_accessor :max_pins_available, :roll_score, :frame_scores | |
| def initialize | |
| @game = [] | |
| @frame_scores = [] | |
| 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
    
  
  
    
  | require 'pry' | |
| class BowlingGame | |
| binding.pry | |
| attr_accessor :total, :game | |
| def initialize | |
| @game = [] | |
| @total = 0 | |
| 9.times {|f| @game << [0,0]} | |
| 9.times {|f| @game[f] = roll_frame(f)} | 
  
    
      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 'pry' | |
| # Determine whether a string contains a Social Security number. | |
| def has_ssn?(string) | |
| string.match(/\d{3}.\d{2}.\d{4}/) ? true : false | |
| end | |
| # Return the Social Security number from a string. | |
| def grab_ssn(string) | |
| string.slice(/\d{3}.\d{2}.\d{4}/) # ? true : false | 
  
    
      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
    
  
  
    
  | def binary_search(search,array) | |
| # binding.pry | |
| array.sort! | |
| @h_i ||= array.size | |
| @m_i ||= array.size / 2 | |
| @l_i ||= 0 | |
| return @m_i if search == array[@m_i] | |
| return -1 if @h_i - @m_i == 1 | |
| if search > array[@m_i] # top half | 
OlderNewer