You are viewing a single comment's thread. Return to all comments →
Here is my c# attempt, feel free to provide feedback, use or comment.
using System.Text.RegularExpressions;
static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int n = -1; string input = ""; char[] trimM = {'(', ')'}; List<string> texts = new List<string>(); string[] operations, separate; string combine = ""; input = Console.ReadLine(); while(input != null) { texts.Add(input); input = Console.ReadLine(); } foreach(string s in texts){ operations = s.Split(";"); switch(operations[0]) { case "S": if(operations[1] == "M") operations[2] = operations[2].Trim(trimM); separate = Regex.Split(operations[2], @"(?<!^)(?=[A-Z])"); foreach(string word in separate) { if(separate.Last() == word) Console.WriteLine(word.ToLower()); else Console.Write(word.ToLower() + " "); } break; case "C": separate = operations[2].Split(" "); foreach(string word in separate) { if(word == separate.First()) { if(operations[1] == "C") combine += word[0].ToString().ToUpper() + word.Substring(1); else combine += word; } else { combine += word[0].ToString().ToUpper() + word.Substring(1); } } if(operations[1] == "M") combine += "()"; Console.WriteLine(combine); combine = ""; break; } } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →
Here is my c# attempt, feel free to provide feedback, use or comment.
using System.Text.RegularExpressions;
}