using System.Collections.Generic;
public string SplitBy { get; set; }
public List<string> Input { get; set; }
public List<string> Output { get; set; }
public List<string> Result { get; set; }
public override string ToString()
return $"SplitBy: {SplitBy}, Input: [{string.Join(",", Input)}], Output: [{string.Join(",", Output)}], Result: [{string.Join(",", Result)}]";
public static void Main()
Console.WriteLine("Input: ");
inputValue = Console.ReadLine();
string processedValue = inputValue.Replace(" ", "");
int numericalOutput = StringToNumber(processedValue);
Console.WriteLine("Input: S = {0}", inputValue);
Console.WriteLine("Output = {0}", numericalOutput);
static List<string> StringToList(string text)
char[] characterArray = text.ToCharArray();
List<string> stringList = new List<string>();
foreach (char character in characterArray)
stringList.Add(character.ToString());
static DecodeModel DecoderText(string text)
DecodeModel response = new DecodeModel();
List<string> tempList = new List<string>();
List<string> finalList = new List<string>();
bool containsAaaa = false;
if (text.Contains("AAAA"))
List<string> textList = StringToList(text);
for (int i = 0; i < textList.Count; i++)
string currentCharacter = textList[i];
string nextCharacter = "";
string potentialAaaa = "";
if (nextIndex3 < textList.Count)
potentialAaaa = currentCharacter + textList[nextIndex] + textList[nextIndex2] + textList[nextIndex3];
if (potentialAaaa == "AAAA")
finalList.Add(potentialAaaa);
textList[nextIndex] = "";
textList[nextIndex2] = "";
textList[nextIndex3] = "";
if (nextIndex < textList.Count)
nextCharacter = textList[nextIndex];
string combinedCharacters = currentCharacter + nextCharacter;
if (CheckText(combinedCharacters))
finalList.Add(combinedCharacters);
if (nextIndex < textList.Count)
textList[nextIndex] = "";
finalList.Add(currentCharacter);
List<string> outputList = new List<string>();
for (int i = 0; i < finalList.Count; i++)
outputList.Add(finalList[i]);
response.Input = textList;
response.Output = outputList;
response.Result = tempList;
static bool CheckText(string text)
static int StringToNumber(string text)
List<string> decodedSegmentsList = new List<string>();
DecodeModel decodedModel = DecoderText(text);
decodedSegmentsList.AddRange(decodedModel.Output);
for (int i = 0; i < decodedSegmentsList.Count; i++)
string segment = decodedSegmentsList[i];