DEV Community

Discussion on: Solving a Job Application Code Challenge

Collapse
 
s3artis profile image
Matt Weingaertner • Edited

Great Post! Thanks!

My C# approach would be something like this:

static void Main(string[] args) {
    var sortedString = longString
        .OrderBy(x => x.Equals('_') ? 2 : 1 )
        .ThenBy(x => x)
        .ToArray(); 
    Console.WriteLine(sortedString); 
}
Collapse
 
s3artis profile image
Matt Weingaertner

The problem with fast shooting, is always the same, mistakes! :/

static void Main(string[] args) {
    var keyString = new string(longString
        .OrderByDescending(x => longString.Count(c => c.Equals(x)))
        .Distinct()               
        .ToArray());             
    Console.WriteLine(keyString.Split('_')[0]); 
}