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 MovieFlight | |
def self.length(flight_length, movie_length) | |
movie_length.each_with_index do |movie, index| | |
remaining_time = (flight_length - movie) | |
movie_length.each_with_index do |m, i| | |
if remaining_time - m == 0 && index != i | |
return true | |
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
require "colorize" | |
require "pry" | |
POSSIBLE_SOLUTIONS = [ | |
["r", "e", "d"], | |
["b", "l", "u", "e"], | |
["o","r", "a", "n", "g", "e"] | |
] | |
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 Dragon | |
def initialize(name, color = "rainbow") | |
@name = name.capitalize | |
@asleep = false | |
@in_belly = 10 # is full | |
@in_intenstine = 0 # doesn't need to poo | |
@hydrated = 10 # this is level of drunken-ness (yes, our dragon drinks whiskey) | |
@color = color | |
if @color == "rainbow" # adding abilities based on color |
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 Planets | |
attr_accessor :name, :pop_by, :diameter, :distance_from_sun, :planets, :good_for_humans | |
def initialize(planet_hash, good_for_humans = true) | |
@name = planet_hash[:name] | |
@pop_by = planet_hash[:pop_by] | |
@diameter = planet_hash[:diameter] | |
@distance_from_sun = planet_hash[:distance_from_sun] | |
@good_for_humans = planet_hash[:good_for_humans] | |
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
# define class | |
class Planet | |
attr_accessor :name, :pop_by, :avg_temp, :color, :rate_solar_rotation, :distance_from_sun, :planets, :add_planet, :print_planets | |
def initialize(name, pop_by, avg_temp, color) | |
@name = name.capitalize | |
@pop_by = pop_by | |
@avg_temp = avg_temp | |
@color = color | |
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
# any input that's not within my calculator's parameters calculates to "nonsense" | |
answer = "nonsense" | |
puts "Please enter an operation (such as add, -, *, divide, exponent, %): " | |
user_op = gets.chomp.downcase | |
puts "Please enter a number: " | |
num_one = gets.chomp | |
puts "Please enter a number: " |
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
# building and sorting an array | |
puts "We're going to play a game!" | |
puts "You're going to list off words." | |
puts "When you're done, hit the enter button on a blank line." | |
puts "I'll tell you which words you listed, in alphabetical order." | |
words = [] | |
answer = 0 |
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
# 99 bottles of beer on the wall | |
count = 99 | |
(99).times do | |
if count > 1 | |
puts "#{count} bottles of beer on the wall," | |
puts "#{count} bottles of beer." | |
puts "Take one down, pass it around," | |
puts "#{count-1} bottles of beer on the wall!" | |
puts "" |
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
# 6.2 part 1 | |
puts "WHAT DO YOU WANT? I AM YOUR BOSS!!!" | |
print "> " | |
answer = gets.chomp.upcase | |
puts "WHAT DO YOU MEAN \"#{answer}\"?!? YOU'RE FIRED!!" | |
# 6.2 part 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
puts "What's your first name?" | |
puts ">" | |
first_name = gets.chomp | |
puts "What's your middle name?" | |
puts ">" | |
middle_name = gets.chomp |
NewerOlder