Hi,
Just talking markdown formatting you should surround snippets with three consecutive backticks. This is why your display is messed up.
ex:
publicstaticvoidMain(string[]args){// Your multiline code can be syntax colored.// Just surround them with triple backticks and optionally a valid language name}
AFAIK you cannot syntax color inline code (i.e. code within a sentence). So the most you can do it put that piece of code between single backticks.
ex:
This sentence mention the public keyword as inline code. Just surround keywords or expressions such as foreach (item in collection) in single backticks.
Talking about your challenge, I'm not sure to understand it too much.
Based on the given example I get to that value in another fashion.
Given your string RLRRLLRLRL I would split it that way which also gives 4.
usingSystem;usingSystem.Text.RegularExpressions;publicclassProgram{publicstaticvoidMain(){strings="RLRRLLRLRL";Console.WriteLine($"Output: {BalancedString(s)}");}// Assuming there can be only 'L' and 'R' in the stringstaticintBalancedString(strings){CheckBalancedString(s);intcount=0;for(inti=0;i<s.Length-1;i++){if(!s[i].Equals(s[i+1])){count++;i++;// Next index is part of the set hence he hop it.}}returncount;}staticvoidCheckBalancedString(strings){Regexr=newRegex("^[LR]*$");if(!r.IsMatch(s))thrownewException("Sentence can only be made of 'L' and 'R' characters.");elseConsole.WriteLine($"{s} matches the expression.");}}
Hi,
Just talking markdown formatting you should surround snippets with three consecutive backticks. This is why your display is messed up.
ex:
AFAIK you cannot syntax color inline code (i.e. code within a sentence). So the most you can do it put that piece of code between single backticks.
ex:
This sentence mention the
public
keyword as inline code. Just surround keywords or expressions such asforeach (item in collection)
in single backticks.Talking about your challenge, I'm not sure to understand it too much.
Based on the given example I get to that value in another fashion.
Given your string
RLRRLLRLRL
I would split it that way which also gives 4.Regards.
I did solve that problem my way with C#.
Here is the code:
I put a link to that .NET Fiddle to play around.