0
Code coach "camel and snake"
I can't for the life of me find a solution for this one. I tried both in python and c#, but it never manages to pass the final test which is locked, so I have no idea what I'm doing wrong!!
3 Respostas
+ 1
And we have no idea what code you tried. Show your code.
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sololearn
{
class Program
{
static void Main(string[] args)
{
string camel = Console.ReadLine();
string snake = "";
for (int i = 0; i< camel.Length; i++)
{
char c = camel[i];
if(char.IsUpper(c))
{
if(i>0 && (char.IsLower(camel[i-1])||(i+1 < camel.Length && char.IsLower(camel[i+1]))))
{
snake += "_";
}
snake += char.ToLower(c);
}
else
{
snake += c;
}
}
Console.WriteLine(snake);
}
}
}
0
Here, it's correct tho. It just fails the final test