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!!

8th Sep 2025, 8:36 PM
Hiba
Hiba - avatar
3 Réponses
+ 1
And we have no idea what code you tried. Show your code.
8th Sep 2025, 8:48 PM
Lisa
Lisa - avatar
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); } } }
8th Sep 2025, 9:13 PM
Hiba
Hiba - avatar
0
Here, it's correct tho. It just fails the final test
8th Sep 2025, 9:14 PM
Hiba
Hiba - avatar