Implement a function that takes a Roman numeral as its argument and returns its value as an integer. You don't need to validate the form of the Rom...
For further actions, you may consider blocking this person and/or reporting abuse
Not working, due to the fact that you ignored that if a value is smaller than the next one it's substracted not added... check the test case MCMXC it should be 1990 and yours is 2210
haha you re right! thanks. Was in a rush. will fix it
Fun solution in elixir
JS solution
if you are going from back to front, it is a bit easier to "parse".
So this time F# instead of my usual C# posts.
Yes, still learning...
My solution in Haskell:
The lexer function takes care of translating roman numeral tokens into numbers, which can be applied to whole string to get array of the respective integers.
The array of integers is then parsed with a recursive function.
I went with case in lexer, since that notation seemed neater than defining function for each argument case.
Using pattern matching and tail recursion in Elixir:
TypeScript
I did mine using JavaScript, not really a fast algorithm but I think it's readable and allows your pals to understand what's going on.
Hah, there were lots of latin freaks out there in the 60s. Nice, didn't know about it.