Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- work in progress
- -- roman numeral thing also ur mom big gay if u read this
- rn = "XX"
- local sum = 0
- local cache = {}
- function findnum(val)
- if val == "I" then
- return 1
- elseif val == "V" then
- return 5
- elseif val == "X" then
- return 10
- elseif val == "L" then
- return 50
- elseif val == "C" then
- return 100
- elseif val == "D" then
- return 500
- elseif val == "M" then
- return 1000
- end
- end
- local savi = nil
- for i=1,#rn do
- local val = string.sub(rn,i,i)
- local num = findnum(val)
- cache[#cache+1] = num
- if i ~= 1 then
- print("DB: "..cache[#cache-1])
- if cache[#cache-1] > cache[#cache] then
- print("DB: "..num)
- sum = sum + num
- else
- for i=1,3 do
- if cache[#cache-i] > cache[#cache] then
- else
- savi = i
- break
- end
- end
- local jum = 0
- for i=1,savi do
- jum = jum + cache[#cache-i]
- end
- num = num - jum
- sum = sum + num
- end
- else
- sum = sum + num
- end
- end
- for i=1,#cache do
- print(cache[i])
- end
- print("________________________\n")
- print(sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement