public bool Match(string input)
        {
            string romanAlphabet = RomanLetters.GetAlphabet();

            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length != 2)
            {
                return(false);
            }

            string roman = parts[1];
            bool   found = false;

            for (int i = 0; i < romanAlphabet.Length; i++)
            {
                if (String.Equals(roman, romanAlphabet[i].ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    found = true;
                    break;
                }
            }

            return(found);
        }
Example #2
0
        public bool ExecuteRule(string input)
        {
            if (input.Length < 3)
            {
                return(true);
            }

            for (int i = input.Length - 1; i >= 2; i--)
            {
                if (RomanLetters.IsSmaller(input[i - 1].ToString(), input[i].ToString()) &&
                    RomanLetters.IsSmaller(input[i - 2].ToString(), input[i].ToString()))
                {
                    Console.WriteLine("SubtractSmallerValueFromLarger Rule has been violated");
                    return(false);
                }
            }

            return(true);
        }