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.
Is there any clean approach without first calculating the value in decimal form? I've passed every test cases of this problem, but I hated it. For the original problem, I used a dict to count the number of consecutive occurrences, and increment total += 3 or += 2 accordingly. But it seems this approach is not suitable for the HackerRank version, where there could be invalid input like VVVVVVVVV.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #89: Roman numerals
You are viewing a single comment's thread. Return to all comments →
Is there any clean approach without first calculating the value in decimal form? I've passed every test cases of this problem, but I hated it. For the original problem, I used a
dict
to count the number of consecutive occurrences, and incrementtotal += 3
or+= 2
accordingly. But it seems this approach is not suitable for the HackerRank version, where there could be invalid input likeVVVVVVVVV
.