diff --git a/CodingChallenge.FamilyTree.Tests/CodingChallenge.FamilyTree.Tests.csproj b/CodingChallenge.FamilyTree.Tests/CodingChallenge.FamilyTree.Tests.csproj
index 07b4591..8e478dc 100644
--- a/CodingChallenge.FamilyTree.Tests/CodingChallenge.FamilyTree.Tests.csproj
+++ b/CodingChallenge.FamilyTree.Tests/CodingChallenge.FamilyTree.Tests.csproj
@@ -71,6 +71,9 @@
CodingChallenge.FamilyTree
+
+
+
diff --git a/CodingChallenge.FamilyTree/Solution.cs b/CodingChallenge.FamilyTree/Solution.cs
index 512487c..d02aabe 100644
--- a/CodingChallenge.FamilyTree/Solution.cs
+++ b/CodingChallenge.FamilyTree/Solution.cs
@@ -1,12 +1,24 @@
using System;
+using System.Linq;
namespace CodingChallenge.FamilyTree
{
public class Solution
{
public string GetBirthMonth(Person person, string descendantName)
+ {
+ var descendant = findDescendant(person, descendantName); // search tree for descendant
+
+ return descendant?.Birthday.ToString("MMMM") ?? string.Empty; // return descendant
+ }
+
+ private Person findDescendant(Person person, string descendantName) // search descendantName
{
- throw new NotImplementedException();
+ return person.Name == descendantName ? person : person.Descendants.Select(i => findDescendant(i, descendantName)).FirstOrDefault(result => result != null); // return descendant or null if not found
}
}
-}
\ No newline at end of file
+}
+
+
+
+
diff --git a/CodingChallenge.PirateSpeak.Tests/CodingChallenge.PirateSpeak.Tests.csproj b/CodingChallenge.PirateSpeak.Tests/CodingChallenge.PirateSpeak.Tests.csproj
index 9dc0f8e..e4a05e1 100644
--- a/CodingChallenge.PirateSpeak.Tests/CodingChallenge.PirateSpeak.Tests.csproj
+++ b/CodingChallenge.PirateSpeak.Tests/CodingChallenge.PirateSpeak.Tests.csproj
@@ -78,6 +78,9 @@
CodingChallenge.PirateSpeak
+
+
+
diff --git a/CodingChallenge.PirateSpeak/Solution.cs b/CodingChallenge.PirateSpeak/Solution.cs
index 2c77075..06422e2 100644
--- a/CodingChallenge.PirateSpeak/Solution.cs
+++ b/CodingChallenge.PirateSpeak/Solution.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
namespace CodingChallenge.PirateSpeak
@@ -7,7 +8,20 @@ public class Solution
{
public string[] GetPossibleWords(string jumble, string[] dictionary)
{
- throw new NotImplementedException();
+ List PossibleWords = new List();
+
+ String UnJumbledWord = String.Concat(jumble.OrderBy(i => i)); // arrange jumble words in alpha. order
+
+ foreach (var word in dictionary)
+ {
+ string dictionaryWord = String.Concat(word.OrderBy(i => i)); // arrange dic. word in alpha. order
+
+ if (dictionaryWord == UnJumbledWord) // if the two are =
+ {
+ PossibleWords.Add(word); // add word to the list
+ }
+ }
+ return PossibleWords.ToArray(); // return list to array
}
}
-}
\ No newline at end of file
+}