We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #89: Roman numerals
Project Euler #89: Roman numerals
Sort by
recency
|
12 Discussions
|
Please Login in order to post a comment
Python 3
Ruby:
I did this worked,it pretty well:
To make your life easier:
string Cs[] = { "","C","CC","CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" }; string Xs[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; string Is[] = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
This Hacker Rank question looks similar to the original Project Euler question, but it's actually quite different.
For the start, Project Euler only requires you "count" the character differences, while Hacker Rank requires you to actually convert to the short form. More problematic difference is that their inputs follow different rules. All of Project Euler inputs are still "valid": e.g. only one 'V' can appear in a string.
I ended up having two different solutions for these questions. I had a solution passing all tests in Hacker Rank, but failing Project Euler.