Skip to content

Instantly share code, notes, and snippets.

@grishace
Last active June 11, 2020 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grishace/73c02f2149130b688ab9d3193c3a096d to your computer and use it in GitHub Desktop.
Save grishace/73c02f2149130b688ab9d3193c3a096d to your computer and use it in GitHub Desktop.
Coderbyte - question marks
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