Skip to content

Instantly share code, notes, and snippets.

View LisaBee224's full-sized avatar

Lisa Buch LisaBee224

View GitHub Profile
def shuffle(array)
comp_array = array.dup
random_nums = []
until random_nums.length == array.length
j = rand(array.length)
if !random_nums.include?(j)
random_nums << j
end
end
def shuffle(array)
comp_array = array.dup
random_nums = []
until random_nums.length == array.length
j = rand(array.length)
if !random_nums.include?(j)
random_nums << j
end
end
def shuffle(array)
random_nums=[]
end
$letters = {
1000 => "M",
500 => "D",
100 => "C",
50 => "L",
10 => "X",
5 => "V",
1 => "I"
}
def convert_to_roman()
options = {}
puts "Enter a number"
num = gets.chomp.to_i
puts "Modern numerals? (Y/N)"
result = gets.chomp
if
result == "Y"
options[:modern] = true
elsif
def convert_to_roman(arabic, options={})
num = arabic
numeral = ""
$letters.each do |key,value|
numeral += value * (num/key)
num -= key * (num/key)
end
if options.has_key?(:modern) && options[:modern] == true
$modern_letters.each do |old_nums, new_nums|
$modern_letters = {
"VIIII" => "IX",
"IIII" => "IV",
"LXXXX" => "XC",
"XXXX" => "XL",
"DCCCC" => "CM",
"CCCC" => "CD"
}
def convert_to_roman(arabic)
numeral = ""
number = arabic
$letters.each do |key, value|
numerals += value * (number / key)
num -= key * (num/key)
end
end
def convert_to_roman(arabic)
numeral = ""
number = arabic
$letters.each do |key, value|
numerals += value * (number / key)
end
end
$letters = {
1000 => "M",
500 => "D",
100 => "C",
50 => "L",
10 => "X",
5 => "V",
1 => "I"
}