-
Practice>Python>Regex and Parsing>Validating Roman Numeralshackerrank.com 2019. 4. 11. 12:47728x90
Validating Roman Numerals
Problem Link : https://www.hackerrank.com/challenges/validate-a-roman-number/problem
Difficulty : Easy
Tip
- Problem itself is simple
- We should under stand what is roman number character
- Here is regular expression, to capture roman number chracter
- (^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$)
- This allows MMMM, so it lead the failure of test case 4
- Please spend some time to read links below
- Best answer for this problem
- https://www.hackerrank.com/challenges/validate-a-roman-number/forum/comments/536680
Good explanation of Roman number character
- http://mathworld.wolfram.com/RomanNumerals.html
- https://stackoverflow.com/questions/267399/how-do-you-match-only-valid-roman-numerals-with-a-regular-expression
Solution
728x90'hackerrank.com' 카테고리의 다른 글
Practice>Python>Regex and Parsing>Validating and Parsing Email Addresses (0) 2019.04.12 Practice>Python>Regex and Parsing>Validating phone numbers (0) 2019.04.11 Practice>Python>Regex and Parsing>Regex Substitution (0) 2019.04.09 Practice>Python>Regex and Parsing>Re.start() & Re.end() (0) 2019.04.04 Practice>Python>Regex and Parsing>Re.findall() & Re.finditer() (0) 2019.04.03