Instantly share code, notes, and snippets.

Embed
What would you like to do?
LinqChallenge3
"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(',')
.Select(x => x[0] == '0' ? '1' : ' ')
.Aggregate("", (x, y) => x += y)
.Split(' ')
.Max(x => x.Length)
"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(';')
.Select(hand => new { orig = hand, grp = hand.Split(' ').Select(card => card[0]).GroupBy(g => g) })
.Where(hand => hand.grp.Count() == 2 && hand.grp.Any(value => value.Count() == 2) && hand.grp.Any(value => value.Count() == 3))
.Select(hand => hand.orig)
Enumerable.Range(2018, 10)
.Select(y => (new DateTime(y, 12, 25)).DayOfWeek)
"parts,traps,arts,rats,starts,tarts,rat,art,tar,tars,stars,stray"
.Split(',')
.Where(word => new string(word.OrderBy(letter => letter).ToArray()) == "arst")
"Santi Cazorla, Per Mertesacker, Alan Smith, Thierry Henry, Alex Song, Paul Merson, Alexis Sánchez, Robert Pires, Dennis Bergkamp, Sol Campbell"
.Split(new[] { ", " }, StringSplitOptions.None)
.GroupBy(name => new string(name.Split(' ').Select(namePart => namePart[0]).ToArray()))
.Where(g => g.Count() > 1)
string.Join(";",
"0:00:00-0:00:05;0:55:12-1:05:02;1:37:47-1:37:51"
.Split('-')
.Skip(1)
.Select(segTimes => segTimes.Contains(";") ? segTimes.Replace(";", "-"): segTimes + "-2:00:00" )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment