Last active
June 11, 2020 15:42
-
-
Save grishace/73c02f2149130b688ab9d3193c3a096d to your computer and use it in GitHub Desktop.
Coderbyte - question marks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static readonly Regex rx = new Regex(@"(\d)(\D+)?"); | |
public static string QuestionsMarks(string str) { | |
var input = rx.Matches(str).Select(m => Tuple.Create(Int32.Parse(m.Groups[1].Value), m.Groups[2].Value)).ToList(); | |
return input | |
.Zip(input.Skip(1), Tuple.Create) | |
.Where(t => t.Item1.Item1 + t.Item2.Item1 == 10) | |
.DefaultIfEmpty(Tuple.Create(Tuple.Create(0, ""), Tuple.Create(0, ""))) | |
.All(t => t.Item1.Item2.Count(c => c == '?') == 3) | |
.ToString() | |
.ToLower(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment