Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 29 additions & 1 deletion CodingChallenge.FamilyTree/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
using System;
using System.Collections.Generic;

namespace CodingChallenge.FamilyTree
{
public class Solution
{
public string GetBirthMonth(Person person, string descendantName)
{
throw new NotImplementedException();
string birthMonth = "";
List<Person> children = new List<Person>();
if (person.Name == descendantName)
{ //it could be him or her self
return person.Birthday.ToString("MMMM");
}
foreach (Person descendant in person.Descendants)
{
if (descendant.Name == descendantName)
{
birthMonth = descendant.Birthday.ToString("MMMM");
break;
}
if (descendant.Descendants.Count > 0) //if child has children add to the list of children
children.AddRange(descendant.Descendants);
}

if (birthMonth == "")
{
foreach (Person descendant in children)
{
birthMonth = GetBirthMonth(descendant, descendantName); //check the children
if (birthMonth != "") break; // this will break recursive function
}
}

return birthMonth;

}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
39 changes: 38 additions & 1 deletion CodingChallenge.PirateSpeak/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace CodingChallenge.PirateSpeak
Expand All @@ -7,7 +8,43 @@ public class Solution
{
public string[] GetPossibleWords(string jumble, string[] dictionary)
{
throw new NotImplementedException();
var listOfStrings = new List<string>();

foreach (string word in dictionary)
{
if (MatchWord(jumble, word))
{
listOfStrings.Add(word);
}
}

string[] arrayOfStrings = listOfStrings.ToArray();
return arrayOfStrings;
}

private bool MatchWord(string jumble, string word)
{
var match = false;
var listOfCharMatchPos = new List<int>();

if (jumble.Length != word.Length)
return false;

foreach (char jchar in jumble)
{
for (int i = 0; i < word.Length; i++)
{
if (!listOfCharMatchPos.Contains(i) && jchar == word[i])
{
listOfCharMatchPos.Add(i);
break;
}
}
}
if (jumble.Length == listOfCharMatchPos.Count)
match = true;

return match;
}
}
}