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 Array_List | |
attr_accessor :initial_size, :list_size, :array_length, :content | |
def initialize | |
@initial_size = 10 | |
@list_size = 0 | |
@array_length = @initial_size | |
@content = Array.new(@initial_size) | |
end | |
def append(element) |
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 BoggleBoard | |
DICE = [['A','A','E','E','G','N'], | |
['E','L','R','T','T','Y'], | |
['A','O','O','T','T','W'], | |
['A','B','B','J','O','O'], | |
['E','H','R','T','V','W'], | |
['C','I','M','O','T','U'], | |
['D','I','S','T','T','Y'], | |
['E','I','O','S','S','T'], | |
['D','E','L','R','V','Y'], |
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 './racer_utils' | |
#assume 'racer_utils' works | |
class RubyRacer | |
attr_reader :players, :length | |
def initialize(players, length = 30) | |
@players = players | |
@length = length | |
@die = Die.new |
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 bottle_song_recursive(n) | |
if n==1 | |
puts "1 bottle of beer on the wall, 1 bottle of beer. Take one down, pass it around, no more bottles of beer on the wall!" | |
else | |
puts "#{n} bottles of beer on the wall, #{n} bottles of beer. Take one down, pass it around, #{n-1} bottles of beer on the wall!" | |
n -= 1 | |
bottle_song_recursive(n) unless n == 0 | |
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
#Turns Integer into a Roman Numeral | |
# Old Roman Numeral | |
puts "What number would you like to convert to Roman Numeral?" | |
def to_roman(number) | |
number = number.to_i | |
str = "" | |
until number < 3000 && number > 0 | |
puts "Please put in a number between 1 and 3000" | |
number = gets.chomp.to_i | |
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
def pig_latin(string1) | |
string1.to_s.downcase! | |
if #If a word begins with a vowel (aeiou), add 'ay' to the end. | |
string1[0] == 'a' || string1[0] == 'e' || string1[0] == 'i' || string1[0] == 'o' || string1[0] == "u" | |
string1 += 'ay' | |
elsif #If a word begins with 'qu', move the 'qu' to the end of the word and add 'ay' after it. | |
string1[0,2] == 'qu' | |
string1 = string1.insert(-1, 'qu') + 'ay' | |
string1 = string1[2..-1] | |
else #If a word begins with a consonant, move it to the end of the word and add 'ay' after it. |
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
#Leap years are divisible by 4 (like 1992 and 1996). | |
#There is an exception, though, and an exception to the exception: | |
#if a year is divisible by 100, it's not a leap year (like 1900), | |
#unless it is also divisible by 400 (like the year 2000). | |
def leap_year? (year) | |
if year%100 == 0 && year%400 == 0 | |
puts "Leap Year!" | |
elsif year%4 == 0 && year%100 != 0 | |
puts "Leap Year!" |
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 leap_year? (year) | |
if year%100 == 0 && year%400 == 0 | |
puts "Leap Year!" | |
elsif year%4 == 0 && year%100 != 0 | |
puts "Leap Year!" | |
else | |
puts "Not Leap Year!" | |
end | |
end |
NewerOlder