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 find_highest_index(array) | |
| second_array = array.clone | |
| while array.count > 1 | |
| first_number = array.first | |
| index = array.index(first_number) | |
| if first_number > array[index + 1] | |
| array.delete_at(index + 1) | |
| else | |
| array.delete_at(index) | |
| 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_relative "top_three" | |
| require 'pry' | |
| require 'rspec' | |
| class WordAnalytics | |
| attr_reader :character_count | |
| def initialize(phrase) | |
| @phrase = phrase |
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 'rspec' | |
| class WordCounter | |
| def initialize(phrase) | |
| @phrase = phrase | |
| @all_words = [] | |
| @uniq_words = [] | |
| @word_count = [] | |
| 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
| #What are the top 50 worst rated movies? | |
| #The results should include the movie title and rating and be sorted by the worst rating first. | |
| SELECT title, rating FROM movies WHERE rating > 1 ORDER BY rating LIMIT 10; | |
| #What movies do not have a rating? The results should include just the movie titles in sorted order. | |
| SELECT title FROM movies WHERE rating IS NULL; | |
| # What movies have the word "thrilling" in their synopsis? The results should just include the movie title. |
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 Circle | |
| def initialize(radius) | |
| @radius = radius | |
| end | |
| def area | |
| (Math::PI * (@radius*@radius)).round(2) | |
| 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 'rspec' | |
| require_relative 'latin' | |
| describe PigLatinTranslation do | |
| it 'should split up all the letters in a phrase' do | |
| expect(PigLatinTranslation.new('i am happy').words).to eql(['iway','amway','appyhay']) | |
| end | |
| it "should translate words that start with a vowel" do | |
| expect(PigLatinTranslation.new(@words_in_phrase = 'happy').words).to eql('appyhay') |
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
| persons_income = [ | |
| { | |
| first_name: 'Johnny', | |
| last_name: 'Smith', | |
| annual_income: 120000, | |
| tax_paid: 28000 | |
| }, | |
| { | |
| first_name: 'Liz', | |
| last_name: 'Lemon', |
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 PigLatinTranslation | |
| attr_reader :phrase | |
| def initialize(phrase) | |
| @phrase = phrase | |
| @words_in_phrase = [] | |
| end | |
| def translate |
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 Animal | |
| attr_reader :animal_name | |
| def initialize(name) | |
| @animal_name = (name) | |
| end | |
| def eat(what_they_eat) | |
| puts "just ate #{what_they_eat}" |
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 AssignmentGrade | |
| def initialize(grade_data) | |
| @student_grades = grade_data | |
| end | |
| def gets_an_asignment_grade(assignment_number) | |
| @student_grades.student_grades.each do |person| | |
| if assignment_number == 1 | |
| puts person[:name] |
NewerOlder