loading...

re: Daily Challenge #15 - Stop gninnipS My sdroW! VIEW POST

FULL DISCUSSION
 

A quick one in C#

 var input = Console.ReadLine().Split(' ');
 var output = new List<string>();
 foreach (var word in input)
 {
    if (word.Length <= 4)
    {
      output.Add(word);
      continue;
    }

    // word reversal. This can be done using inbuilt functions as well
    var wordArray = word.ToCharArray();
    var current = string.Empty;
    for (int i = word.Length - 1; i >= 0 ; i--)
    {
       current += wordArray[i];
    }

    output.Add(current);
 }

 Console.WriteLine(string.Join(" ", output));
 Console.ReadKey();
code of conduct - report abuse