Last active
August 7, 2018 21:26
-
-
Save htoma/fcd05739cf95379183bbea192bb10f39 to your computer and use it in GitHub Desktop.
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
public static List<string> Anagrams() | |
{ | |
var star = string.Join("", "star".OrderBy(l => l)); | |
return "parts,traps,arts,rats,starts,tarts,rat,art,tar,tars,stars,stray" | |
.Split(',') | |
.Where(w => w.Length == star.Length && string.Join("", w.OrderBy(l => l)).Contains(star)).ToList(); | |
} |
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
public static List<string> ChristmasDayOfTheWeek() | |
{ | |
var start = new DateTime(2018, 12, 25); | |
return Enumerable.Range(0, 8) | |
.Select(y => start.AddYears(y)) | |
.Select(d => d.DayOfWeek.ToString()).ToList(); | |
} |
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
public static List<string> FullHouseHands() | |
{ | |
var hands = "4♣ 5♦ 6♦ 7♠ 10♥;10♣ Q♥ 10♠ Q♠ 10♦;6♣ 6♥ 6♠ A♠ 6♦;2♣ 3♥ 3♠ 2♠ 2♦;2♣ 3♣ 4♣ 5♠ 6♠" | |
.Split(';'); | |
var indexes = hands | |
.Select((h, index) => (index: index, | |
hand: h.Split(new[] {' ', '♣', '♦', '♠', '♥'}, StringSplitOptions.RemoveEmptyEntries))) | |
.Select(t => (index: t.index, groups: t.hand.GroupBy(y => y))) | |
.Where(t => t.groups.Count() == 2 && t.groups.First().Count() == 3) | |
.Select(t => t.index); | |
return indexes.Select(i => hands[i]).ToList(); | |
} |
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
public static int LongestSequenceOfZeroes() | |
{ | |
return "1,2,1,1,0,3,1,0,0,2,4,1,0,0,0,0,2,1,0,3,1,0,0,0,6,1,3,0,0,0" | |
.Split(',') | |
.Aggregate((l: 0, m: 0), | |
(t, s) => s == "0" | |
? (t.l + 1, Math.Max(t.l + 1, t.m)) | |
: (0, t.m)).m; | |
} |
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
public static string VideoEditing() | |
{ | |
var cuts = ("0:00:00-0:00:05;0:55:12-1:05:02;1:37:47-1:37:51" + "-2:00:00") | |
.Split(new[] {'-', ';'}, StringSplitOptions.RemoveEmptyEntries); | |
return string.Join(";", Enumerable.Range(0, cuts.Length / 2) | |
.Select(i => $"{cuts[i * 2 + 1]}-{cuts[(i + 1) * 2]}")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment