Skip to content

Instantly share code, notes, and snippets.

@LisaBee224
Created April 12, 2016 03:20
Show Gist options
  • Save LisaBee224/ea08568c1b11c6e74c00120476604743 to your computer and use it in GitHub Desktop.
Save LisaBee224/ea08568c1b11c6e74c00120476604743 to your computer and use it in GitHub Desktop.
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
result == "N"
options[:modern] = false
else
puts "sorry, not a valid value"
exit
end
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|
numeral.sub!(old_nums, new_nums)
end
end
p numeral
end
convert_to_roman()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment