Created
May 1, 2011 20:24
-
-
Save MikeBild/950830 to your computer and use it in GitHub Desktop.
Code Kata PickAkin
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
/* | |
http://ilker.de/code-kata-pickakin | |
akinList = [A1,B2,A2,A3,B3,A4,D1,D2,B1] | |
ceoList = [C1,E1,E2] | |
controlList = [F1] | |
*/ | |
var ceoListOriginal = new List<string>() {"A1", "B1", "A2", "A3", "C1", "D1", "E1", "E2"}; | |
var controlListOriginal = new List<string>() {"F1", "D2", "B2", "B3", "A4"}; | |
var ceoListPart = (from ceo in ceoListOriginal | |
select ceo.Substring(0, 1)); | |
var controlListPart = (from cl in controlListOriginal | |
select cl.Substring(0, 1)); | |
var akinList = | |
(from l in ceoListPart.Intersect(controlListPart) | |
from o in ceoListOriginal | |
where o.Substring(0, 1) == l | |
select o) | |
.Union | |
(from l in ceoListPart.Intersect(controlListPart) | |
from o in controlListOriginal | |
where o.Substring(0, 1) == l | |
select o) | |
.ToList(); | |
var ceoList = (from l in ceoListPart.Except(controlListPart) | |
from o in ceoListOriginal | |
where o.Substring(0, 1) == l | |
select o) | |
.ToList(); | |
var controlList = (from l in controlListPart.Except(ceoListPart) | |
from o in controlListOriginal | |
where o.Substring(0, 1) == l | |
select o) | |
.ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment