Skip to content

Instantly share code, notes, and snippets.

@MikeBild
Created May 1, 2011 20:24
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 MikeBild/950830 to your computer and use it in GitHub Desktop.
Save MikeBild/950830 to your computer and use it in GitHub Desktop.
Code Kata PickAkin
/*
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