Hello.
I have to write an algorithm for finding all possible roman numbers from a string. I shouldn’t use brute force, but I have to use proper algorithm and/or proper data structure. Can someone give me any advice where to start, cause I can’t remeber anything except brute force solution for it.
Thank you
Use a regular expression, and that happens to be one of the samples I wrote for RegExRX.
\b(?=[IVXLCDM]+\b)M*(?:CM|DC{0,3}|CD|C{1,3})?(?:XC|LX{0,3}|XL|X{1,3})?(?:IX|VI{0,3}|IV|I{1,3})?\b
You can use RegEx in Xojo: https://www.oreilly.com/library/view/regular-expressions-cookbook/9780596802837/ch06s09.html
we have some RegEx kings here in the forum.
Edit: the King of RegEx was faster than me 
Homework?
Unlikely a regex solution will suffice.
‘explain your algorithm’.

1 Like