Skip to content

Instantly share code, notes, and snippets.

@TrevMcKendrick
Created October 11, 2013 16:06
Show Gist options
  • Save TrevMcKendrick/6937468 to your computer and use it in GitHub Desktop.
Save TrevMcKendrick/6937468 to your computer and use it in GitHub Desktop.
require 'pry'
class Integer
Roman_hash = {
1 => "I",
5 => "V",
10 => "X",
50 => "L",
100 => "C",
500 => "D",
1000 => "M"
}
def largest_divisor
Roman_hash.each_key do |x|
end
end
def to_roman
Roman_hash[self]
end
binding.pry
end
#take the number 750
Fill as much as possible with the higheset roman numeral that isn't higher
D = 500
Take the remainder
250
repeat until...
C - 100
150
c - 100
50
L = 50
-----
String back together
19
X = 10
9
V = 5
4
if there are for of the same character in a row, replace with one of them, plus the next biggest
iiii => iV
450
CCCC
50
L
CDL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment