├── App.Algorithms.15.04.LCS
├── App.config
├── SearchDirection.cs
├── LcsLengthCell.cs
├── LcsSearchContext.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── LcsFinder.cs
└── App.Algorithms.15.04.LCS.csproj
├── App.Problems.BlockSizes
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── App.Problems.BlockSizes.csproj
└── Program.cs
├── App.Problems.BoggleWords
├── App.config
├── BoggleDice.cs
├── DigitalTreeNode.cs
├── WordPathNode.cs
├── WordDictionary.cs
├── RandomNumberEnumerator.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── BoggleBoard.cs
├── DigitalTree.cs
├── App.Problems.BoggleWords.csproj
└── BoggleWordFinder.cs
├── App.Problems.DigitalTrees
├── App.config
├── DigitalTreeNode.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── DigitalTree.cs
└── App.Problems.DigitalTrees.csproj
├── App.Problems.Enumerators
├── App.config
├── RangeOfIntegers.cs
├── RangeOfIntegersYieldingEnumerable.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── RangeOfIntegersStandardEnumerable.cs
└── App.Problems.Enumerators.csproj
├── App.Problems.Fibonacci
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── Program.cs
└── App.Problems.Fibonacci.csproj
├── App.Problems.GraphRoadTrip
├── App.config
├── RoadTripMagnitudeResult.cs
├── Node.cs
├── Properties
│ └── AssemblyInfo.cs
├── Graph.cs
├── App.Problems.GraphRoadTrip.csproj
└── Program.cs
├── App.Problems.Palindrome
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── App.Problems.Palindrome.csproj
├── App.Problems.PriorityQueue
├── App.config
├── Program.cs
├── PrioirtyQueue.cs
├── Properties
│ └── AssemblyInfo.cs
└── App.Problems.PriorityQueue.csproj
├── App.Problems.PyramidHeight
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── App.Problems.PyramidHeight.csproj
└── Program.cs
├── App.Problems.TicTacToe
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── Program.cs
├── README.md
├── App.Problems.TicTacToe.csproj
├── BetterTicTacToeBoard.cs
├── FastTicTacToeBoard.cs
└── SlowTicTacToeBoard.cs
├── App.Algorithms.15.01.RodCutting
├── App.config
├── RodCutterBase.cs
├── RodCutterResult.cs
├── SlowRodCutter.cs
├── MemoizedRodCutter.cs
├── Program.cs
├── BottomUpRodCutter.cs
├── Properties
│ └── AssemblyInfo.cs
└── App.Algorithms.15.01.RodCutting.csproj
├── App.Problems.BinaryTreeIterator
├── App.config
├── BinaryTreeNode.cs
├── RecursivelyEnumerableBinaryTreeWrapper.cs
├── Properties
│ └── AssemblyInfo.cs
├── App.Problems.BinaryTreeIterator.csproj
├── Program.cs
└── BinaryTree.cs
├── App.Problems.SpiralIntoMatrix
├── App.config
├── Properties
│ └── AssemblyInfo.cs
├── Program.cs
└── App.Problems.SpiralIntoMatrix.csproj
├── App.Algorithms.04.01.MaxSubarray
├── App.config
├── MaxSubarrayResult.cs
├── MaxSubarrayFinderBase.cs
├── BruteForceFinder.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── IterativeFinder.cs
├── DivideAndConquerFinder.cs
└── App.Algorithms.04.01.MaxSubarray.csproj
├── App.Problems.ParseTimeFromString
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── App.Problems.ParseTimeFromString.csproj
└── Parser.cs
├── App.Problems.RubiksCube
├── App.Problems.RubiksCube.csproj
├── Program.cs
├── CubeCell.cs
├── CubeFace.cs
└── Cube.cs
├── App.Problems.NumberToEnglish
├── App.Problems.NumberToEnglish.csproj
├── Program.cs
└── EnglishNumberConverter.cs
├── App.Problems.SnakesAndLadders
├── App.Problems.SnakesAndLadders.csproj
├── Program.cs
└── SnakesAndLaddersBoard.cs
├── LICENSE
├── .gitattributes
├── .gitignore
├── README.md
└── ProgrammingPractice.sln
/App.Algorithms.15.04.LCS/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.BlockSizes/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.Fibonacci/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.Palindrome/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.PriorityQueue/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.PyramidHeight/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/RodCutterBase.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Algorithms.RodCutting
3 | {
4 | public abstract class RodCutterBase
5 | {
6 | public abstract RodCutterResult CutRods(int[] prices, int rodLength);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.SpiralIntoMatrix/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.ParseTimeFromString/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/App.Problems.RubiksCube/App.Problems.RubiksCube.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/RoadTripMagnitudeResult.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.GraphRoadTrip
3 | {
4 | class RoadTripMagnitudeResult
5 | {
6 | public Node Node { get; set; }
7 |
8 | public int Magnitude { get; set; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/App.Problems.RubiksCube/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.RubiksCube
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Console.WriteLine("Hello World!");
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/App.Problems.NumberToEnglish/App.Problems.NumberToEnglish.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/App.Problems.SnakesAndLadders/App.Problems.SnakesAndLadders.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/MaxSubarrayResult.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Algorithms.MaxSubarray
3 | {
4 | public class MaxSubarrayResult
5 | {
6 | public int StartIndex { get; set; }
7 |
8 | public int EndIndex { get; set; }
9 |
10 | public int Value { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/SearchDirection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Algorithms.LCS
8 | {
9 | public enum SearchDirection
10 | {
11 | None,
12 | Up,
13 | Left,
14 | Right,
15 | Down,
16 | Diagonal
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/LcsLengthCell.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Algorithms.LCS
8 | {
9 | public class LcsLengthCell
10 | {
11 | public SearchDirection Direction { get; set; }
12 |
13 | public int Length { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/MaxSubarrayFinderBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Algorithms.MaxSubarray
8 | {
9 | public abstract class MaxSubarrayFinderBase
10 | {
11 | public abstract MaxSubarrayResult FindMaxSubarray(int[] values);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/BinaryTreeNode.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.BinaryTreeIterator
3 | {
4 | public class BinaryTreeNode
5 | {
6 | public BinaryTreeNode ParentNode { get; set; }
7 |
8 | public BinaryTreeNode LeftNode { get; set; }
9 |
10 | public BinaryTreeNode RightNode { get; set; }
11 |
12 | public TData Data { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/Node.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.GraphRoadTrip
4 | {
5 | class Node
6 | {
7 | public Node()
8 | {
9 | Neighbors = new List();
10 | }
11 |
12 | public string Name { get; set; }
13 |
14 | public int Population { get; set; }
15 |
16 | public List Neighbors { get; private set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/BoggleDice.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.BoggleWords
3 | {
4 | class BoggleDice
5 | {
6 | public BoggleDice(string firstChars, string secondChars)
7 | {
8 | FirstChars = firstChars;
9 | SecondChars = secondChars;
10 | }
11 |
12 | public string FirstChars { get; private set; }
13 |
14 | public string SecondChars { get; private set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/App.Problems.RubiksCube/CubeCell.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace App.Problems.RubiksCube
6 | {
7 | class CubeCell
8 | {
9 | public CubeCell(int color)
10 | {
11 | Color = color;
12 | }
13 |
14 | public int Color { get; }
15 |
16 | public string Label { get; }
17 |
18 | public string TempLabel { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/DigitalTreeNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.BoggleWords
4 | {
5 | public class DigitalTreeNode
6 | {
7 | public DigitalTreeNode()
8 | {
9 | NextNodes = new Dictionary();
10 | }
11 |
12 | public Dictionary NextNodes { get; private set; }
13 |
14 | public bool IsCompleteWord { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/DigitalTreeNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.DigitalTrees
4 | {
5 | public class DigitalTreeNode
6 | {
7 | public DigitalTreeNode()
8 | {
9 | NextNodes = new Dictionary();
10 | }
11 |
12 | public Dictionary NextNodes { get; private set; }
13 |
14 | public bool IsCompleteWord { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/WordPathNode.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.BoggleWords
3 | {
4 | class WordPathNode
5 | {
6 | public WordPathNode(int row, int column, char character)
7 | {
8 | Row = row;
9 | Column = column;
10 | Character = character;
11 | }
12 |
13 | public int Row { get; private set; }
14 |
15 | public int Column { get; private set; }
16 |
17 | public char Character { get; private set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/LcsSearchContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Algorithms.LCS
8 | {
9 | public class LcsSearchContext
10 | {
11 | public LcsLengthCell[,] LcsLengthsTable { get; set; }
12 |
13 | public StringBuilder Output { get; set; }
14 |
15 | public string X { get; set; }
16 |
17 | public string Y { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/RodCutterResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Algorithms.RodCutting
4 | {
5 | public class RodCutterResult
6 | {
7 | static RodCutterResult()
8 | {
9 | Empty = new RodCutterResult();
10 | }
11 |
12 | public RodCutterResult()
13 | {
14 | CutLengths = new List();
15 | TotalPrice = 0;
16 | }
17 |
18 | public int TotalPrice { get; set; }
19 |
20 | public List CutLengths { get; private set; }
21 |
22 | public static RodCutterResult Empty { get; private set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/WordDictionary.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace App.Problems.BoggleWords
4 | {
5 | class WordDictionary
6 | {
7 | public WordDictionary()
8 | {
9 | InnerTree = new DigitalTree();
10 | }
11 |
12 | private DigitalTree InnerTree { get; set; }
13 |
14 | public DigitalTreeNode RootTreeNode => InnerTree.RootNode;
15 |
16 | public void LoadWords(string[] words)
17 | {
18 | InnerTree.LoadWords(words);
19 | }
20 |
21 | public void LoadWords(Stream words)
22 | {
23 | InnerTree.LoadWords(words);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/App.Problems.RubiksCube/CubeFace.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace App.Problems.RubiksCube
6 | {
7 | public class CubeFace
8 | {
9 | public CubeFace(int color)
10 | {
11 | Cells = new CubeCell[4, 4];
12 |
13 | for (int row=0; row < 4; row++)
14 | {
15 | for (int col=0; col < 4; col++)
16 | {
17 | Cells[row, col] = new CubeCell(color);
18 | }
19 | }
20 | }
21 |
22 | private CubeCell[,] Cells { get; }
23 |
24 | private CubeFace Up { get; }
25 |
26 | private CubeFace Down { get; }
27 |
28 | private CubeFace Right { get; }
29 |
30 | private CubeFace Left { get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/App.Problems.PriorityQueue/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Problems.PriorityQueue
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | var priorityQueue = new PriorityQueue();
14 |
15 | priorityQueue.Enqueue(100, "Lowest prioirty item");
16 | priorityQueue.Enqueue(1, "A high priority item");
17 | priorityQueue.Enqueue(1, "Another high priority item");
18 | priorityQueue.Enqueue(10, "A middle priority item");
19 |
20 | while (priorityQueue.Count != 0)
21 | {
22 | var item = priorityQueue.Dequeue();
23 | Console.WriteLine(item);
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/RangeOfIntegers.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.Enumerators
3 | {
4 | class RangeOfIntegers
5 | {
6 | public RangeOfIntegers()
7 | {
8 | FirstValue = 0;
9 | LastValue = -1;
10 | }
11 |
12 | public RangeOfIntegers(int firstValue, int lastValue)
13 | {
14 | FirstValue = firstValue;
15 | LastValue = lastValue;
16 | }
17 |
18 | public int FirstValue { get; set; }
19 |
20 | public int LastValue { get; set; }
21 |
22 | public RangeOfIntegersStandardEnumerable GetStandardEnumerable()
23 | {
24 | return new RangeOfIntegersStandardEnumerable(this);
25 | }
26 |
27 | public RangeOfIntegersYieldingEnumerable GetYieldingEnumerable()
28 | {
29 | return new RangeOfIntegersYieldingEnumerable(this);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/App.Problems.ParseTimeFromString/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.ParseTimeFromString
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | // Given a string of the form "Retries: 2; TotalTime: 10000; TotalTime: 5000; TotalTime: 2000", write
10 | // a function that returns the total time
11 | //
12 | // The number of TotalTime occurrences is 1 + the number of Retries.
13 | //
14 | // DO NOT use regular expressions or any higher-level existing methods such as .NET's built-in
15 | // Int32.Parse() or Int32.TryParse().
16 |
17 | var parser = new Parser();
18 |
19 | int sum = parser.GetTotalTimeSum("Retries: 2; TotalTime: 10000; TotalTime: 5000; TotalTime: 2000");
20 |
21 | Console.WriteLine(sum);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/App.Problems.Palindrome/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.Palindrome
4 | {
5 | class Program
6 | {
7 | static bool IsPalindrome(string s)
8 | {
9 | // A simple function to determine if an arbitrary string is a Palindrome.
10 |
11 | if (s.Length <= 1)
12 | return true;
13 |
14 | for (int index = 0; index < s.Length / 2; index++)
15 | {
16 | if (s[index] != s[s.Length - 1 - index])
17 | return false;
18 | }
19 |
20 | return true;
21 | }
22 |
23 | static void Main(string[] args)
24 | {
25 | string[] testWords = { "", "x", "kevin", "kayak", "bb", "ab", "abba", "aba", "bbc" };
26 |
27 | foreach (string word in testWords)
28 | {
29 | Console.WriteLine("Word: '{0}', IsPalindrome: {1}", word, IsPalindrome(word));
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/RangeOfIntegersYieldingEnumerable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 |
4 | namespace App.Problems.Enumerators
5 | {
6 | class RangeOfIntegersYieldingEnumerable : IEnumerable
7 | {
8 | public RangeOfIntegersYieldingEnumerable(RangeOfIntegers innerRange)
9 | {
10 | InnerRange = innerRange;
11 | }
12 |
13 | public RangeOfIntegers InnerRange { get; private set; }
14 |
15 | private IEnumerator GetInnerEnumerator()
16 | {
17 | for (int x = InnerRange.FirstValue; x <= InnerRange.LastValue; x++)
18 | yield return x;
19 | }
20 |
21 | IEnumerator IEnumerable.GetEnumerator()
22 | {
23 | return GetInnerEnumerator();
24 | }
25 |
26 | IEnumerator IEnumerable.GetEnumerator()
27 | {
28 | return GetInnerEnumerator();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/BruteForceFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.MaxSubarray
4 | {
5 | public class BruteForceFinder : MaxSubarrayFinderBase
6 | {
7 | public override MaxSubarrayResult FindMaxSubarray(int[] values)
8 | {
9 | // A slow, O(n^2) algorithm
10 |
11 | var result = new MaxSubarrayResult() { Value = Int32.MinValue };
12 |
13 | for (int startIndex = 0; startIndex < values.Length; startIndex++)
14 | {
15 | int sum = 0;
16 |
17 | for (int endIndex = startIndex; endIndex < values.Length; endIndex++)
18 | {
19 | sum += values[endIndex];
20 | if (sum > result.Value)
21 | {
22 | result.StartIndex = startIndex;
23 | result.EndIndex = endIndex;
24 | result.Value = sum;
25 | }
26 | }
27 | }
28 |
29 | return result;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/App.Problems.SnakesAndLadders/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.SnakesAndLadders
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | var input = new int[,]
10 | {
11 | { -1, -1, -1, -1, -1, -1 },
12 | { -1, -1, -1, -1, -1, -1 },
13 | { -1, -1, -1, -1, -1, -1 },
14 | { -1, 35, -1, -1, 13, -1 },
15 | { -1, -1, -1, -1, -1, -1 },
16 | { -1, 15, -1, -1, -1, -1 }
17 | };
18 |
19 | //var input = new int[,]
20 | //{
21 | // { -1, -1, -1, -1, -1, -1 },
22 | // { -1, -1, -1, -1, -1, -1 },
23 | // { -1, -1, -1, -1, -1, -1 },
24 | // { -1, 2, -1, -1, 2, -1 },
25 | // { 2, 2, 2, 2, 2, 2 },
26 | // { -1, 2, 2, 2, 2, 2 }
27 | //};
28 |
29 | var board = new SnakesAndLaddersBoard(6, input);
30 |
31 | Console.WriteLine(board.Solve());
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/SlowRodCutter.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Algorithms.RodCutting
3 | {
4 | public class SlowRodCutter : RodCutterBase
5 | {
6 | public override RodCutterResult CutRods(int[] prices, int rodLength)
7 | {
8 | if (rodLength <= 0)
9 | return RodCutterResult.Empty;
10 |
11 | RodCutterResult bestResult = new RodCutterResult();
12 |
13 | for (int i = 1; i <= rodLength && i <= prices.Length; i++)
14 | {
15 | var innerResult = CutRods(prices, rodLength - i);
16 |
17 | if (innerResult.TotalPrice + prices[i - 1] > bestResult.TotalPrice)
18 | {
19 | bestResult.CutLengths.Clear();
20 | bestResult.CutLengths.Add(i);
21 | bestResult.CutLengths.AddRange(innerResult.CutLengths);
22 | bestResult.TotalPrice = prices[i - 1] + innerResult.TotalPrice;
23 | }
24 | }
25 |
26 | return bestResult;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/App.Problems.RubiksCube/Cube.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace App.Problems.RubiksCube
6 | {
7 | public class Cube
8 | {
9 |
10 | public Cube()
11 | {
12 | var blueFace = new CubeFace(0);
13 | var redFace = new CubeFace(1);
14 | var greenFace = new CubeFace(2);
15 | var orangeFace = new CubeFace(3);
16 | var yellowFace = new CubeFace(4);
17 | var whiteFace = new CubeFace(5);
18 |
19 | Top = blueFace;
20 | Front = redFace;
21 | Bottom = greenFace;
22 | Back = orangeFace;
23 | Right = yellowFace;
24 | Left = whiteFace;
25 | }
26 |
27 | public CubeFace Top { get; private set; }
28 |
29 | public CubeFace Front { get; private set; }
30 |
31 | public CubeFace Bottom { get; private set; }
32 |
33 | public CubeFace Back { get; private set; }
34 |
35 | public CubeFace Right { get; private set; }
36 |
37 | public CubeFace Left { get; private set; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.Enumerators
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | // Just a simple program to demonstrate how to write Enumerators using C#,
10 | // both with the traditional Reset/MoveNext/Current style, and using yield return.
11 |
12 | var myRange = new RangeOfIntegers(10, 20);
13 |
14 | Console.WriteLine();
15 | Console.WriteLine("List Range of Integers with Standard Enumerator");
16 | Console.WriteLine("-----------------------------------------------");
17 |
18 | foreach (int val in myRange.GetStandardEnumerable())
19 | Console.WriteLine(val);
20 |
21 | Console.WriteLine();
22 |
23 | Console.WriteLine("List Range of Integers with Yielding Enumerator");
24 | Console.WriteLine("-----------------------------------------------");
25 |
26 | foreach (int val in myRange.GetYieldingEnumerable())
27 | Console.WriteLine(val);
28 |
29 | Console.WriteLine();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/RandomNumberEnumerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace App.Problems.BoggleWords
6 | {
7 | class RandomNumberEnumerator : IEnumerable
8 | {
9 | public RandomNumberEnumerator(int size)
10 | {
11 | Size = size;
12 | }
13 |
14 | public int Size { get; private set; }
15 |
16 | private IEnumerator GetInnerEnumerator()
17 | {
18 | var numbers = new List();
19 | var rng = new Random();
20 |
21 | for (int x = 0; x < Size; x++)
22 | numbers.Add(x);
23 |
24 | for (int x = Size - 1; x >= 0; x--)
25 | {
26 | var random = rng.Next(0, x);
27 | var nextNumber = numbers[random];
28 | numbers.RemoveAt(random);
29 |
30 | yield return nextNumber;
31 | }
32 | }
33 |
34 | IEnumerator IEnumerable.GetEnumerator()
35 | {
36 | return GetInnerEnumerator();
37 | }
38 |
39 | IEnumerator IEnumerable.GetEnumerator()
40 | {
41 | return GetInnerEnumerator();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 kevinknowscs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.LCS
4 | {
5 | internal class Program
6 | {
7 | private static void PrintResults(string x, string y, string lcs)
8 | {
9 | Console.WriteLine();
10 | Console.WriteLine("x = {0}", x);
11 | Console.WriteLine("y = {0}", y);
12 | Console.WriteLine("Longest Common Subsequence = {0}", lcs);
13 | }
14 |
15 | internal static void Main(string[] args)
16 | {
17 | // Compute the "Longest Common Subsequence" of two input strings, per the
18 | // dynamic programming algorithm outlined in Section 15.4 of Introduction to Algorithms
19 |
20 | string x, y;
21 | var lcsFinder = new LcsFinder();
22 |
23 | x = "ABCBDAB";
24 | y = "BDCABA";
25 | PrintResults(x, y, lcsFinder.FindLcs(x, y));
26 |
27 | x = "ACCGGTCGAGTGCGCGGAAGCCGGCCGAA";
28 | y = "GTCGTTCGGAATGCCGTTGCTCTGTAAA";
29 | PrintResults(x, y, lcsFinder.FindLcs(x, y));
30 |
31 | x = "10010101";
32 | y = "010110110";
33 | PrintResults(x, y, lcsFinder.FindLcs(x, y));
34 |
35 | Console.WriteLine();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.MaxSubarray
4 | {
5 | class Program
6 | {
7 | static void PrintResult(string method, MaxSubarrayResult result)
8 | {
9 | string heading = "Max Subarray Result, Method = ";
10 |
11 | Console.WriteLine("{0}{1}", heading, method);
12 | Console.WriteLine(new String('-', heading.Length + method.Length));
13 |
14 | Console.WriteLine("Start Index: {0}", result.StartIndex);
15 | Console.WriteLine("End Index : {0}", result.EndIndex);
16 | Console.WriteLine("Value : {0}", result.Value);
17 | Console.WriteLine();
18 | }
19 |
20 | static void Main(string[] args)
21 | {
22 | int[] data = { 0, 13, -3, -25, -20, -3, -16, -23, 18, 20, -7, 12, -5, -22, 15, -4, 7 };
23 |
24 | var bruteForce = new BruteForceFinder();
25 | var divideAndConquer = new DivideAndConquerFinder();
26 | var iterative = new IterativeFinder();
27 |
28 | PrintResult("Brute Force", bruteForce.FindMaxSubarray(data));
29 | PrintResult("Divide and Conquer", divideAndConquer.FindMaxSubarray(data));
30 | PrintResult("Iterative", iterative.FindMaxSubarray(data));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/App.Problems.PriorityQueue/PrioirtyQueue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace App.Problems.PriorityQueue
6 | {
7 | public class PriorityQueue
8 | {
9 | public PriorityQueue()
10 | {
11 | Items = new SortedDictionary>();
12 | Count = 0;
13 | }
14 |
15 | private SortedDictionary> Items { get; set; }
16 |
17 | public int Count { get; private set; }
18 |
19 | public bool IsEmpty => Count == 0;
20 |
21 | public PriorityQueue Enqueue(int priority, T item)
22 | {
23 | Queue queue;
24 |
25 | if (!Items.TryGetValue(priority, out queue))
26 | {
27 | queue = new Queue();
28 | Items.Add(priority, queue);
29 | }
30 |
31 | queue.Enqueue(item);
32 | Count++;
33 |
34 | return this;
35 | }
36 |
37 | public T Dequeue()
38 | {
39 | if (Count == 0)
40 | throw new Exception("Queue is empty");
41 |
42 | var firstPriority = Items.First();
43 | var queue = firstPriority.Value;
44 |
45 | T item = queue.Dequeue();
46 | Count--;
47 |
48 | if (queue.Count == 0)
49 | Items.Remove(firstPriority.Key);
50 |
51 | return item;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace App.Problems.BoggleWords
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | var wordDictionary = new WordDictionary();
11 |
12 | wordDictionary.LoadWords(Assembly.GetExecutingAssembly().GetManifestResourceStream("App.Problems.BoggleWords.Dictionary.txt"));
13 |
14 | // Have fun with it and try different board sizes
15 | var boggleBoard = new BoggleBoard(4, 4);
16 |
17 | boggleBoard.Print();
18 | Console.WriteLine();
19 |
20 | var finder = new BoggleWordFinder(boggleBoard, wordDictionary);
21 | var results = finder.FindWords();
22 |
23 | Console.WriteLine("Found {0} words", results.Count);
24 | Console.WriteLine();
25 |
26 | int index = 1;
27 |
28 | foreach (var pathList in results)
29 | {
30 | Console.Write("Word {0} : ", index++);
31 |
32 | foreach (var wordPathNode in pathList)
33 | Console.Write(wordPathNode.Character);
34 |
35 | Console.Write(" ");
36 |
37 | foreach (var wordPathNode in pathList)
38 | {
39 | Console.Write("({0}, {1}) = {2} ", wordPathNode.Row, wordPathNode.Column, wordPathNode.Character);
40 | }
41 |
42 | Console.WriteLine();
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/MemoizedRodCutter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Algorithms.RodCutting
4 | {
5 | public class MemoizedRodCutter : RodCutterBase
6 | {
7 | private RodCutterResult CutRods(int[] prices, int rodLength, Dictionary priorResults)
8 | {
9 | if (rodLength <= 0)
10 | return RodCutterResult.Empty;
11 |
12 | if (priorResults.ContainsKey(rodLength))
13 | return priorResults[rodLength];
14 |
15 | RodCutterResult bestResult = new RodCutterResult();
16 |
17 | for (int i = 1; i <= rodLength && i <= prices.Length; i++)
18 | {
19 | var innerResult = CutRods(prices, rodLength - i, priorResults);
20 |
21 | if (innerResult.TotalPrice + prices[i - 1] > bestResult.TotalPrice)
22 | {
23 | bestResult.CutLengths.Clear();
24 | bestResult.CutLengths.Add(i);
25 | bestResult.CutLengths.AddRange(innerResult.CutLengths);
26 | bestResult.TotalPrice = prices[i - 1] + innerResult.TotalPrice;
27 | }
28 | }
29 |
30 | priorResults.Add(rodLength, bestResult);
31 |
32 | return bestResult;
33 | }
34 |
35 | public override RodCutterResult CutRods(int[] prices, int rodLength)
36 | {
37 | return CutRods(prices, rodLength, new Dictionary());
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.RodCutting
4 | {
5 | class Program
6 | {
7 | static void PrintResults(int[] prices, string name, RodCutterBase rodCutter)
8 | {
9 | string header = "Cutting Rods: ";
10 |
11 | Console.WriteLine(header + name);
12 | Console.WriteLine(new String('-', header.Length + name.Length));
13 |
14 | int index = 0;
15 | var result = rodCutter.CutRods(prices, 99);
16 |
17 | foreach (var length in result.CutLengths)
18 | {
19 | Console.WriteLine("Cut: {0}, Length: {1}, Price: {2}", (index++) + 1, length, prices[length - 1]);
20 | }
21 |
22 | Console.WriteLine();
23 | Console.WriteLine("Total Price of Cut Rods: {0}", result.TotalPrice);
24 | Console.WriteLine();
25 | }
26 |
27 | static void Main(string[] args)
28 | {
29 | int[] prices = { 1, 5, 8, 9, 10, 17, 17, 20, 24, 30 };
30 |
31 | var slowRodCutter = new SlowRodCutter();
32 | var memoizedRodCutter = new MemoizedRodCutter();
33 | var bottomUpRodCutter = new BottomUpRodCutter();
34 |
35 | Console.WriteLine();
36 |
37 | // PrintResults(prices, "Slow Version", slowRodCutter);
38 | PrintResults(prices, "Memoized Version", memoizedRodCutter);
39 | PrintResults(prices, "Bottom Up Version", bottomUpRodCutter);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/BottomUpRodCutter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace App.Algorithms.RodCutting
5 | {
6 | public class BottomUpRodCutter : RodCutterBase
7 | {
8 | public override RodCutterResult CutRods(int[] prices, int rodLength)
9 | {
10 | if (rodLength <= 0)
11 | return RodCutterResult.Empty;
12 |
13 | var results = new Dictionary();
14 |
15 | results.Add(0, RodCutterResult.Empty);
16 |
17 | for (int j = 1; j <= rodLength; j++)
18 | {
19 | int maxPrice = Int32.MinValue;
20 | int maxLength = 0;
21 | RodCutterResult maxPriorResult = null;
22 |
23 | for (int i = 1; i <= j && i <= prices.Length; i++)
24 | {
25 | int currPrice = prices[i - 1] + results[j - i].TotalPrice;
26 | if (currPrice > maxPrice)
27 | {
28 | maxPrice = currPrice;
29 | maxLength = i;
30 | maxPriorResult = results[j - i];
31 | }
32 | }
33 |
34 | var currResult = new RodCutterResult();
35 |
36 | currResult.TotalPrice = maxPrice;
37 | currResult.CutLengths.Add(maxLength);
38 | currResult.CutLengths.AddRange(maxPriorResult.CutLengths);
39 |
40 | results.Add(j, currResult);
41 | }
42 |
43 | return results[rodLength];
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.DigitalTrees
4 | {
5 | ///
6 | /// A simple implementation of a digital search tree that can store and
7 | /// find words with similar prefixes
8 | ///
9 |
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | var digitalTree = new DigitalTree();
15 |
16 | var words = new string[]
17 | {
18 | "",
19 | "about",
20 | "above",
21 | "across",
22 | "after",
23 | "along",
24 | "among",
25 | "around",
26 | "at",
27 | "before",
28 | "behind",
29 | "below"
30 | };
31 |
32 | digitalTree.LoadWords(words);
33 |
34 | var testWords = new string[]
35 | {
36 | "about",
37 | "abo",
38 | "ab",
39 | "above",
40 | "missing",
41 | "aboutxxx",
42 | ""
43 | };
44 |
45 | foreach (string testWord in testWords)
46 | {
47 | Console.WriteLine("'{0}' : {1}", testWord, digitalTree.ContainsWord(testWord) ? "Found" : "Not Found");
48 | }
49 |
50 | Console.WriteLine();
51 | Console.WriteLine("Here are the words in the dictionary");
52 | Console.WriteLine("------------------------------------");
53 |
54 | foreach (string word in digitalTree)
55 | Console.WriteLine("'{0}'", word);
56 |
57 | Console.WriteLine();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/RecursivelyEnumerableBinaryTreeWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace App.Problems.BinaryTreeIterator
6 | {
7 | public class RecursivelyEnumerableBinaryTreeWrapper : IEnumerable
8 | {
9 | // This class demonstrates how to use "yield return" recursively
10 |
11 | public RecursivelyEnumerableBinaryTreeWrapper(BinaryTree tree)
12 | {
13 | Tree = tree;
14 | }
15 |
16 | public BinaryTree Tree { get; set; }
17 |
18 | private IEnumerable EnumerateNodes(BinaryTreeNode node)
19 | {
20 | if (node == null)
21 | yield break;
22 |
23 | if (node.LeftNode != null)
24 | {
25 | foreach (TData val in EnumerateNodes(node.LeftNode))
26 | yield return val;
27 | }
28 |
29 | yield return node.Data;
30 |
31 | if (node.RightNode != null)
32 | {
33 | foreach (TData val in EnumerateNodes(node.RightNode))
34 | yield return val;
35 | }
36 | }
37 |
38 | private IEnumerator InnerEnumerator()
39 | {
40 | foreach (TData val in EnumerateNodes(Tree.RootNode))
41 | yield return val;
42 | }
43 |
44 | IEnumerator IEnumerable.GetEnumerator()
45 | {
46 | return this.InnerEnumerator();
47 | }
48 |
49 | IEnumerator IEnumerable.GetEnumerator()
50 | {
51 | return this.InnerEnumerator();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/App.Problems.Fibonacci/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Fibonacci")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Fibonacci")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("99e4e3e1-f3bb-4547-b734-4172147d51aa")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.PyramidHeight/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.PyramidHeight")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.PyramidHeight")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("5f76635a-a9f4-474f-aab7-b992f4391338")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.TicTacToe")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.TicTacToe")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("21fc4b75-5d20-4bd2-a806-5b8970100be6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Algorithms.15.04.LCS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Algorithms.15.04.LCS")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("55ed5d74-4c5f-4c5b-83a1-4bbcd0588731")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.BlockSizes/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.BlockSizes")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.BlockSizes")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f63ad16c-f586-4ea6-bf6c-c6856b9d0c61")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.BoggleWords")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.BoggleWords")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cd373a4e-fd7f-4290-9f6b-f78791e30626")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.Palindrome/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems..Palindrome")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems..Palindrome")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ba89ae5e-567e-47bd-a61e-0c67bc9bd1ef")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.DigitalTrees")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.DigitalTrees")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("948164b7-4f99-4aab-bcce-11a4575ce3ae")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.Enumerators.cs")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.Enumerators.cs")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6a313b1d-bc06-4de1-b70c-8caa2e3ca479")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.PriorityQueue/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.PriorityQueue")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.PriorityQueue")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("37781cd6-8056-4262-bc70-c5f90e9df420")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Apps.Problems.GraphRoadTrip")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Apps.Problems.GraphRoadTrip")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1cb5f543-2c73-48bb-bd4a-c632f743e594")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.Fibonacci/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.Fibonacci
4 | {
5 | class Program
6 | {
7 | static int RecursiveFibonacci(int n)
8 | {
9 | // An easy, but slow Fibonacci generator - O(2 ^ n)
10 |
11 | if (n == 0)
12 | return 0;
13 |
14 | if (n == 1)
15 | return 1;
16 |
17 | return RecursiveFibonacci(n - 2) + RecursiveFibonacci(n - 1);
18 | }
19 |
20 | static int FastFibonacci(int n)
21 | {
22 | // A fast, iterative Fibonacci generator - O(n)
23 |
24 | if (n == 0)
25 | return 0;
26 |
27 | if (n == 1)
28 | return 1;
29 |
30 | int fibNMinus2 = 0;
31 | int fibNMinus1 = 1;
32 | int fibCurrent = 0;
33 |
34 | for (int x = 2; x <= n; x++)
35 | {
36 | fibCurrent = fibNMinus1 + fibNMinus2;
37 |
38 | fibNMinus2 = fibNMinus1;
39 | fibNMinus1 = fibCurrent;
40 | }
41 |
42 | return fibCurrent;
43 | }
44 |
45 | static void Main(string[] args)
46 | {
47 | Console.WriteLine("Recursive Fibonacci Algorithm");
48 | Console.WriteLine("-----------------------------");
49 |
50 | for (int x = 0; x < 20; x++)
51 | Console.WriteLine("Fib({0}) = {1}", x, RecursiveFibonacci(x));
52 |
53 | Console.WriteLine();
54 | Console.WriteLine("Fast Fibonacci Algorithm");
55 | Console.WriteLine("------------------------");
56 |
57 | for (int x = 0; x < 20; x++)
58 | Console.WriteLine("Fib({0}) = {1}", x, FastFibonacci(x));
59 |
60 | Console.WriteLine();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/App.Problems.SpiralIntoMatrix/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.SpiralIntoMatrix")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.SpiralIntoMatrix")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("38693bc4-9b35-48af-b785-07792bccdb2b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Algorithms.15.01.RodCutting")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Algorithms.15.01.RodCutting")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("dc4cc736-ba84-4c3d-aad6-189420d3e5e4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.BinaryTreeIterator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.BinaryTreeIterator")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ebf8b214-f389-4797-914e-dfbf1e99b003")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Algorithms.04.01.MaxSubarray")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Algorithms.04.01.MaxSubarray")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9fb8f23a-fdcb-45ac-8950-69caa2f2bea4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.ParseTimeFromString/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("App.Problems.ParseTimeFromString")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("App.Problems.ParseTimeFromString")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cb3561a5-fe75-4df2-a3e4-738e5c182ca6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/RangeOfIntegersStandardEnumerable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 |
4 | namespace App.Problems.Enumerators
5 | {
6 | class RangeOfIntegersStandardEnumerable : IEnumerable
7 | {
8 | public RangeOfIntegersStandardEnumerable(RangeOfIntegers innerRange)
9 | {
10 | InnerRange = innerRange;
11 | }
12 |
13 | public RangeOfIntegers InnerRange { get; private set; }
14 |
15 | private IEnumerator GetInnerEnumerator()
16 | {
17 | return new StandardEnumerator(this);
18 | }
19 |
20 | IEnumerator IEnumerable.GetEnumerator()
21 | {
22 | return GetInnerEnumerator();
23 | }
24 |
25 | IEnumerator IEnumerable.GetEnumerator()
26 | {
27 | return GetInnerEnumerator();
28 | }
29 |
30 | private class StandardEnumerator : IEnumerator
31 | {
32 | public StandardEnumerator(RangeOfIntegersStandardEnumerable owner)
33 | {
34 | Owner = owner;
35 | CurrentValue = Owner.InnerRange.FirstValue - 1;
36 | }
37 |
38 | public RangeOfIntegersStandardEnumerable Owner { get; private set; }
39 |
40 | private int CurrentValue { get; set; }
41 |
42 | object IEnumerator.Current => CurrentValue;
43 |
44 | int IEnumerator.Current => CurrentValue;
45 |
46 | public bool MoveNext()
47 | {
48 | if (CurrentValue >= Owner.InnerRange.LastValue)
49 | return false;
50 |
51 | CurrentValue++;
52 |
53 | return true;
54 | }
55 |
56 | public void Reset()
57 | {
58 | CurrentValue = Owner.InnerRange.FirstValue - 1;
59 | }
60 |
61 | public void Dispose()
62 | {
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/Graph.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.GraphRoadTrip
4 | {
5 | class Graph
6 | {
7 | public Graph()
8 | {
9 | Nodes = new List();
10 | Magnitudes = new Dictionary();
11 | Populations = new Dictionary, int>();
12 | }
13 |
14 | public List Nodes { get; private set; }
15 |
16 | public Dictionary Magnitudes { get; set; }
17 |
18 | public Dictionary, int> Populations { get; set; }
19 |
20 | public RoadTripMagnitudeResult GetRoadTripMagnitude(Node node)
21 | {
22 | RoadTripMagnitudeResult result;
23 |
24 | if (Magnitudes.TryGetValue(node, out result))
25 | return result;
26 |
27 | result = new RoadTripMagnitudeResult() { Magnitude = 0 };
28 |
29 | foreach (var neighbor in node.Neighbors)
30 | {
31 | int neighborPopulation = GetPopulation(neighbor, node);
32 |
33 | if (neighborPopulation > result.Magnitude)
34 | {
35 | result.Node = neighbor;
36 | result.Magnitude = neighborPopulation;
37 | }
38 | }
39 |
40 | Magnitudes.Add(node, result);
41 |
42 | return result;
43 | }
44 |
45 | private int GetPopulation(Node node, Node excludeNode)
46 | {
47 | int population;
48 | var key = new KeyValuePair(node, excludeNode);
49 |
50 | if (Populations.TryGetValue(key, out population))
51 | return population;
52 |
53 | population = node.Population;
54 |
55 | foreach (var neighbor in node.Neighbors)
56 | {
57 | if (neighbor != excludeNode)
58 | population += GetPopulation(neighbor, node);
59 | }
60 |
61 | Populations[key] = population;
62 |
63 | return population;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.TicTacToe
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | // var board = new SlowTicTacToeBoard(3);
10 | // var board = new BetterTicTacToeBoard(3);
11 | var board = new FastTicTacToeBoard(3);
12 |
13 | // 1 = X
14 | // 2 = 0
15 |
16 | // | |
17 | // ---+---+---
18 | // | X |
19 | // ---+---+---
20 | // | |
21 | if (board.MakeMoveAndCheckForWin(1, 1, 1))
22 | Console.WriteLine("X has won the game");
23 |
24 | // O | |
25 | // ---+---+---
26 | // | X |
27 | // ---+---+---
28 | // | |
29 | if (board.MakeMoveAndCheckForWin(0, 0, 2))
30 | Console.WriteLine("O has won the game");
31 |
32 | // O | |
33 | // ---+---+---
34 | // | X |
35 | // ---+---+---
36 | // | | X
37 | if (board.MakeMoveAndCheckForWin(2, 2, 1))
38 | Console.WriteLine("X has won the game");
39 |
40 | // O | O |
41 | // ---+---+---
42 | // | X |
43 | // ---+---+---
44 | // | | X
45 | if (board.MakeMoveAndCheckForWin(0, 1, 2))
46 | Console.WriteLine("O has won the game");
47 |
48 | // O | O | X
49 | // ---+---+---
50 | // | X |
51 | // ---+---+---
52 | // | | X
53 | if (board.MakeMoveAndCheckForWin(0, 2, 1))
54 | Console.WriteLine("X has won the game");
55 |
56 | // O | O | X
57 | // ---+---+---
58 | // | X | O
59 | // ---+---+---
60 | // | | X
61 | if (board.MakeMoveAndCheckForWin(1, 2, 2))
62 | Console.WriteLine("O has won the game");
63 |
64 | // O | O | X
65 | // ---+---+---
66 | // | X | O
67 | // ---+---+---
68 | // X | | X
69 | //
70 | // X Wins
71 | if (board.MakeMoveAndCheckForWin(2, 0, 1))
72 | Console.WriteLine("X has won the game");
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/IterativeFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.MaxSubarray
4 | {
5 | public class IterativeFinder : MaxSubarrayFinderBase
6 | {
7 | public override MaxSubarrayResult FindMaxSubarray(int[] values)
8 | {
9 | // Fast algorithm by Kadane - O(n)
10 | //
11 | // Discussed briefly in Section 4.1-5 of Introduction to Algorithms, the reader
12 | // is encouraged to develop a non-recursive solution. This algorithm is also known
13 | // as Kadane's algorithm.
14 | //
15 | // More information: https://en.wikipedia.org/wiki/Maximum_subarray_problem
16 | //
17 | // My algorithm here is just slightly enhanced to track the start and end index, as
18 | // well as the actual value.
19 | //
20 | // This is a simple form of dynamic programming - results of solving subproblems
21 | // are passed up the solution chain.
22 |
23 | var result = new MaxSubarrayResult()
24 | {
25 | StartIndex = -1,
26 | EndIndex = -1,
27 | Value = Int32.MinValue
28 | };
29 |
30 | if (values.Length == 0)
31 | return result;
32 |
33 | result.StartIndex = 0;
34 | result.EndIndex = 0;
35 | result.Value = values[0];
36 |
37 | int currStartIndex = 0;
38 | int currEndIndex = 0;
39 | int currMax = values[0];
40 |
41 | for (int endIndex = 1; endIndex < values.Length; endIndex++)
42 | {
43 | if (currMax + values[endIndex] > values[endIndex])
44 | {
45 | currMax += values[endIndex];
46 | currEndIndex = endIndex;
47 | }
48 | else
49 | {
50 | currStartIndex = endIndex;
51 | currEndIndex = endIndex;
52 | currMax = values[endIndex];
53 | }
54 |
55 | if (currMax > result.Value)
56 | {
57 | result.StartIndex = currStartIndex;
58 | result.EndIndex = currEndIndex;
59 | result.Value = currMax;
60 | }
61 | }
62 |
63 | return result;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/App.Problems.SpiralIntoMatrix/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.SpiralIntoMatrix
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | int rowCount = 6;
10 | int colCount = 7;
11 |
12 | // States:
13 | // 0 -> Going left-to-right across a row
14 | // 1 -> Going top-to-bottom down a column
15 | // 2 -> Going right-to-left across a row
16 | // 3 -> Going bottom-to-top up a column
17 |
18 | int state = 0;
19 | int currRow = 0;
20 | int currCol = 0;
21 | int completedTopRow = -1;
22 | int completedBottomRow = rowCount;
23 | int completedLeftCol = -1;
24 | int completedRightCol = colCount;
25 |
26 | // There's more than one way to do this. Here I demonstrate how to use
27 | // a simple state machine to keep track of whether I'm moving right, down,
28 | // left, or up;
29 |
30 | for (int x = 0; x < rowCount * colCount; x++)
31 | {
32 | // Visit the current cell
33 | Console.WriteLine("Visiting {0}, {1}", currRow, currCol);
34 |
35 | switch (state)
36 | {
37 | case 0:
38 | if (currCol < completedRightCol - 1)
39 | currCol++;
40 | else
41 | {
42 | completedTopRow++;
43 | currRow++;
44 | state = 1;
45 | }
46 | break;
47 |
48 | case 1:
49 | if (currRow < completedBottomRow - 1)
50 | currRow++;
51 | else
52 | {
53 | completedRightCol--;
54 | currCol--;
55 | state = 2;
56 | }
57 | break;
58 |
59 | case 2:
60 | if (currCol > completedLeftCol + 1)
61 | currCol--;
62 | else
63 | {
64 | completedBottomRow--;
65 | currRow--;
66 | state = 3;
67 | }
68 | break;
69 |
70 | case 3:
71 | if (currRow > completedTopRow + 1)
72 | currRow--;
73 | else
74 | {
75 | completedLeftCol++;
76 | currCol++;
77 | state = 0;
78 | }
79 | break;
80 | }
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/LcsFinder.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace App.Algorithms.LCS
4 | {
5 | public class LcsFinder
6 | {
7 | private LcsLengthCell[,] BuildLcsLengthsTable(string x, string y)
8 | {
9 | var result = new LcsLengthCell[x.Length + 1, y.Length + 1];
10 |
11 | for (int i = 1; i <= x.Length; i++)
12 | result[i, 0] = new LcsLengthCell() { Direction = SearchDirection.None, Length = 0 };
13 |
14 | for (int j = 1; j <= y.Length; j++)
15 | result[0, j] = new LcsLengthCell() { Direction = SearchDirection.None, Length = 0 };
16 |
17 | for (int i = 1; i <= x.Length; i++)
18 | {
19 | for (int j = 1; j <= y.Length; j++)
20 | {
21 | if (x[i - 1] == y[j - 1])
22 | result[i, j] = new LcsLengthCell() { Direction = SearchDirection.Diagonal, Length = result[i - 1, j - 1].Length + 1 };
23 | else if (result[i - 1, j].Length >= result[i, j - 1].Length)
24 | result[i, j] = new LcsLengthCell() { Direction = SearchDirection.Up, Length = result[i - 1, j].Length };
25 | else
26 | result[i, j] = new LcsLengthCell() { Direction = SearchDirection.Left, Length = result[i, j - 1].Length };
27 | }
28 | }
29 |
30 | return result;
31 | }
32 |
33 | private void FindLcs(LcsSearchContext context, int lengthOfX, int lengthOfY)
34 | {
35 | if (lengthOfX == 0 || lengthOfY == 0)
36 | return;
37 |
38 | if (context.LcsLengthsTable[lengthOfX, lengthOfY].Direction == SearchDirection.Diagonal)
39 | {
40 | FindLcs(context, lengthOfX - 1, lengthOfY - 1);
41 | context.Output.Append(context.X[lengthOfX - 1]);
42 | }
43 | else if (context.LcsLengthsTable[lengthOfX, lengthOfY].Direction == SearchDirection.Up)
44 | {
45 | FindLcs(context, lengthOfX - 1, lengthOfY);
46 | }
47 | else
48 | {
49 | FindLcs(context, lengthOfX, lengthOfY - 1);
50 | }
51 | }
52 |
53 | public string FindLcs(string x, string y)
54 | {
55 | var context = new LcsSearchContext();
56 |
57 | context.X = x;
58 | context.Y = y;
59 | context.Output = new StringBuilder();
60 | context.LcsLengthsTable = BuildLcsLengthsTable(x, y);
61 |
62 | FindLcs(context, x.Length, y.Length);
63 |
64 | return context.Output.ToString();
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/DigitalTree.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace App.Problems.DigitalTrees
6 | {
7 | public class DigitalTree : IEnumerable
8 | {
9 | public DigitalTree()
10 | {
11 | RootNode = new DigitalTreeNode();
12 | }
13 |
14 | public DigitalTreeNode RootNode { get; private set; }
15 |
16 | public void LoadWords(string[] words)
17 | {
18 | DigitalTreeNode currNode, newNode;
19 |
20 | foreach (string word in words)
21 | {
22 | currNode = RootNode;
23 |
24 | foreach (char ch in word)
25 | {
26 | if (currNode.NextNodes.ContainsKey(ch))
27 | currNode = currNode.NextNodes[ch];
28 | else
29 | {
30 | newNode = new DigitalTreeNode();
31 | currNode.NextNodes.Add(ch, newNode);
32 | currNode = newNode;
33 | }
34 | }
35 |
36 | currNode.IsCompleteWord = true;
37 | }
38 | }
39 |
40 | public bool ContainsWord(string word)
41 | {
42 | DigitalTreeNode currNode = RootNode;
43 |
44 | foreach (char ch in word)
45 | {
46 | if (!currNode.NextNodes.ContainsKey(ch))
47 | return false;
48 |
49 | currNode = currNode.NextNodes[ch];
50 | }
51 |
52 | return (currNode == null) ? false : currNode.IsCompleteWord;
53 | }
54 |
55 | private IEnumerable InnerEnumerator(DigitalTreeNode currNode, StringBuilder prefix)
56 | {
57 | if (currNode.IsCompleteWord)
58 | yield return prefix.ToString();
59 |
60 | foreach (char ch in currNode.NextNodes.Keys)
61 | {
62 | prefix.Append(ch);
63 |
64 | foreach (string word in InnerEnumerator(currNode.NextNodes[ch], prefix))
65 | yield return word;
66 |
67 | prefix.Remove(prefix.Length - 1, 1);
68 | }
69 | }
70 |
71 | private IEnumerator InnerEnumerator()
72 | {
73 | var prefix = new StringBuilder();
74 |
75 | foreach (string word in InnerEnumerator(RootNode, prefix))
76 | yield return word;
77 | }
78 |
79 | IEnumerator IEnumerable.GetEnumerator()
80 | {
81 | return this.InnerEnumerator();
82 | }
83 |
84 | IEnumerator IEnumerable.GetEnumerator()
85 | {
86 | return this.InnerEnumerator();
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/BoggleBoard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.BoggleWords
4 | {
5 | class BoggleBoard
6 | {
7 | private BoggleDice[] classicGameDice =
8 | {
9 | new BoggleDice("AACIOT", " "),
10 | new BoggleDice("ABILTY", " "),
11 | new BoggleDice("ABJMOQ", " U"),
12 | new BoggleDice("ACDEMP", " "),
13 | new BoggleDice("ACELRS", " "),
14 | new BoggleDice("ADENVZ", " "),
15 | new BoggleDice("AHMORS", " "),
16 | new BoggleDice("BIFORX", " "),
17 | new BoggleDice("DENOSW", " "),
18 | new BoggleDice("DKNOTU", " "),
19 | new BoggleDice("EEFHIY", " "),
20 | new BoggleDice("EGKLUY", " "),
21 | new BoggleDice("EGINTV", " "),
22 | new BoggleDice("EHINPS", " "),
23 | new BoggleDice("ELPSTU", " "),
24 | new BoggleDice("GILRUW", " "),
25 | };
26 |
27 | private BoggleDice[,] boardLayout;
28 |
29 | private int[,] selectedSides;
30 |
31 | public BoggleBoard(int rowCount, int columnCount)
32 | {
33 | RowCount = rowCount;
34 | ColumnCount = columnCount;
35 |
36 | boardLayout = new BoggleDice[rowCount, columnCount];
37 | selectedSides = new int[rowCount, columnCount];
38 |
39 | int index = 0;
40 | foreach (int randomNumber in new RandomNumberEnumerator(rowCount * columnCount))
41 | {
42 | boardLayout[index / columnCount, index % columnCount] = classicGameDice[randomNumber % classicGameDice.Length];
43 | index++;
44 | }
45 |
46 | var rng = new Random();
47 |
48 | for (int row = 0; row < rowCount; row++)
49 | {
50 | for (int col = 0; col < columnCount; col++)
51 | {
52 | selectedSides[row, col] = rng.Next(0, 5);
53 | }
54 | }
55 | }
56 |
57 | public int RowCount { get; private set; }
58 |
59 | public int ColumnCount { get; private set; }
60 |
61 | public char GetCharacter(int row, int col)
62 | {
63 | return boardLayout[row, col].FirstChars[selectedSides[row, col]];
64 | }
65 |
66 | public void Print()
67 | {
68 | for (int row=0; row < RowCount; row++)
69 | {
70 | for (int col=0; col < ColumnCount; col++)
71 | {
72 | Console.Write("{0} ", GetCharacter(row, col));
73 | }
74 |
75 | Console.WriteLine();
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/README.md:
--------------------------------------------------------------------------------
1 |
2 | ##Original Question:
3 | The original question was purposely rather vague: Write a function that records a move on a tic-tac-toe board and
4 | returns true if the player has won, otherwise false. The exact structure and parameters of the function are not
5 | specified - it's up to you to design it.
6 |
7 | ##Clarifying Questions:
8 | Upon inquiry, it was determined that the solution should work for any arbitrarily-sized Tic-Tac-Toe board.
9 |
10 | Other potential clarify questions: Is the Tic-Tac-Toe board empty to begin with, or are we jumping into the middle
11 | of a game. For the solutions presented here, I assume we start at the beginning of the game with an empty board.
12 |
13 | ##Method Signature
14 | bool MakeMoveAndCheckForWin(int row, int col, int playerId);
15 |
16 | row - a 0-based index indicating the row of the move
17 | col - a 0-based index indicating the column of the move
18 | playerId - 1 = X, 2 = 0, 0 is reserved to indicate an empty cell
19 |
20 | ##Design Decisions
21 | * I represented the board as a two-dimensional array. This gives fast access for storing the entire state of the
22 | game, but requires O(n^2) of pre-allocated space, where n is the number of rows or columns. Another option would
23 | be to use a hash table or dictionary to avoid pre-allocated space, but as the moves are made and the board starts
24 | to fill up, it will degrade into O(n^2) space storage anyway, so I think its just as well to pre-allocate the space
25 | in an array.
26 | * How do we check for a win?
27 | * Slow method - O(N^2) : Rescan the entire board on each move
28 | * Better method - O(N) : Rescan only the row, column, and diagonals (if any) of the current move
29 | * Fast method - O(1) : Maintain counters for each row, column, and diagonal instead of rescanning.
30 | * Other considerations
31 | * If we implement the fast method, we may not need to store the entire state of the game.
32 | The only reason to store the entire state of the game would be to check for invalid moves.
33 | * If we knew that N were no larger than a certain value (8, 16, 32, 64) we could design a more efficient
34 | space storage using bit masks. But since the problem stated an arbitrarily-sized board, I do not consider
35 | using bit masks for storage.
36 | * I use standard C# for loops to iterate and scan cells. If one wanted to write more elegant code, you could
37 | use built-in framework functionality such as LINQ.
38 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/DivideAndConquerFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Algorithms.MaxSubarray
4 | {
5 | public class DivideAndConquerFinder : MaxSubarrayFinderBase
6 | {
7 | public MaxSubarrayResult FindMaxThroughMid(int[] values, int startIndex, int midIndex, int endIndex)
8 | {
9 | var result = new MaxSubarrayResult()
10 | {
11 | StartIndex = -1,
12 | EndIndex = -1,
13 | Value = Int32.MinValue
14 | };
15 |
16 | int maxLeft = Int32.MinValue;
17 | int leftSum = 0;
18 |
19 | for (int index = midIndex; index >= startIndex; index--)
20 | {
21 | leftSum += values[index];
22 | if (leftSum > maxLeft)
23 | {
24 | result.StartIndex = index;
25 | maxLeft = leftSum;
26 | }
27 | }
28 |
29 | int maxRight = Int32.MinValue;
30 | int rightSum = 0;
31 |
32 | for (int index = midIndex + 1; index <= endIndex; index++)
33 | {
34 | rightSum += values[index];
35 | if (rightSum > maxRight)
36 | {
37 | result.EndIndex = index;
38 | maxRight = rightSum;
39 | }
40 | }
41 |
42 | result.Value = maxLeft + maxRight;
43 |
44 | return result;
45 | }
46 |
47 |
48 | public MaxSubarrayResult FindMaxSubarray(int[] values, int startIndex, int endIndex)
49 | {
50 | // Divide and Conquer algorithm - O(n * log[n])
51 |
52 | var result = new MaxSubarrayResult();
53 |
54 | if (startIndex == endIndex)
55 | {
56 | result.StartIndex = startIndex;
57 | result.EndIndex = endIndex;
58 | result.Value = values[startIndex];
59 |
60 | return result;
61 | }
62 |
63 | int midIndex = (startIndex + endIndex) / 2;
64 |
65 | var leftResult = FindMaxSubarray(values, startIndex, midIndex);
66 | var rightResult = FindMaxSubarray(values, midIndex + 1, endIndex);
67 | var midResult = FindMaxThroughMid(values, startIndex, midIndex, endIndex);
68 |
69 | if (leftResult.Value >= midResult.Value && leftResult.Value >= rightResult.Value)
70 | return leftResult;
71 |
72 | if (rightResult.Value >= leftResult.Value && rightResult.Value >= midResult.Value)
73 | return rightResult;
74 |
75 | return midResult;
76 | }
77 |
78 | public override MaxSubarrayResult FindMaxSubarray(int[] values)
79 | {
80 | return FindMaxSubarray(values, 0, values.Length - 1);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/App.Problems.Fibonacci/App.Problems.Fibonacci.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {99E4E3E1-F3BB-4547-B734-4172147D51AA}
8 | Exe
9 | App.Fibonacci
10 | App.Fibonacci
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/App.Problems.PyramidHeight/App.Problems.PyramidHeight.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {5F76635A-A9F4-474F-AAB7-B992F4391338}
8 | Exe
9 | App.PyramidHeight
10 | App.PyramidHeight
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/App.Problems.BlockSizes/App.Problems.BlockSizes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}
8 | Exe
9 | App.Problems.BlockSizes
10 | App.Problems.BlockSizes
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/App.Problems.Palindrome/App.Problems.Palindrome.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}
8 | Exe
9 | App.Problems.Palindrome
10 | App.Problems._.Palindrome
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/App.Problems.SpiralIntoMatrix/App.Problems.SpiralIntoMatrix.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {38693BC4-9B35-48AF-B785-07792BCCDB2B}
8 | Exe
9 | App.Problems.SpiralIntoMatrix
10 | App.Problems.SpiralIntoMatrix
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/App.Problems.PriorityQueue/App.Problems.PriorityQueue.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {37781CD6-8056-4262-BC70-C5F90E9DF420}
8 | Exe
9 | App.Problems.PriorityQueue
10 | App.Problems.PriorityQueue
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/App.Problems.ParseTimeFromString/App.Problems.ParseTimeFromString.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}
8 | Exe
9 | App.Problems.ParseTimeFromString
10 | App.Problems.ParseTimeFromString
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/App.Problems.ParseTimeFromString/Parser.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace App.Problems.ParseTimeFromString
3 | {
4 | public class Parser
5 | {
6 | private const string RetriesLabel = "Retries";
7 | private const string TotalTimeLabel = "TotalTime";
8 |
9 | private int SkipChar(string val, int pos, char ch)
10 | {
11 | while (pos < val.Length && val[pos] == ch)
12 | pos++;
13 |
14 | return pos;
15 | }
16 |
17 | private int SkipColon(string val, int pos)
18 | {
19 | // I could just build the : and the space into the
20 | // labels themselves, but this is a little cleaner
21 | return SkipChar(val, pos, ':');
22 | }
23 |
24 | private int SkipSemicolon(string val, int pos)
25 | {
26 | return SkipChar(val, pos, ';');
27 | }
28 |
29 | private int SkipSpaces(string val, int pos)
30 | {
31 | return SkipChar(val, pos, ' ');
32 | }
33 |
34 | private bool IsDigit(char ch)
35 | {
36 | return ch >= '0' && ch <= '9';
37 | }
38 |
39 | private int GetIntFromChar(char ch)
40 | {
41 | return (int)(ch - '0');
42 | }
43 |
44 | private int GetNextValue(string val, int pos, out int result)
45 | {
46 | result = 0;
47 |
48 | while (pos < val.Length && IsDigit(val[pos]))
49 | result = result * 10 + GetIntFromChar(val[pos++]);
50 |
51 | pos = SkipSpaces(val, pos);
52 | pos = SkipSemicolon(val, pos);
53 | pos = SkipSpaces(val, pos);
54 |
55 | return pos;
56 | }
57 |
58 | private int GetNextLabeledValue(string val, int pos, string label, out int result)
59 | {
60 | result = 0;
61 |
62 | pos += label.Length;
63 | pos = SkipColon(val, pos);
64 | pos = SkipSpaces(val, pos);
65 |
66 | return GetNextValue(val, pos, out result);
67 | }
68 |
69 | private int GetRetries(string val, int pos, out int result)
70 | {
71 | return GetNextLabeledValue(val, pos, RetriesLabel, out result);
72 | }
73 |
74 | private int GetTotalTime(string val, int pos, out int result)
75 | {
76 | return GetNextLabeledValue(val, pos, TotalTimeLabel, out result);
77 | }
78 |
79 | public int GetTotalTimeSum(string val)
80 | {
81 | int pos = 0;
82 | int retries = 0;
83 | int totalTime = 0;
84 | int sum = 0;
85 |
86 | pos = GetRetries(val, pos, out retries);
87 |
88 | for (int x=0; x < retries + 1; x++)
89 | {
90 | pos = GetTotalTime(val, pos, out totalTime);
91 | sum += totalTime;
92 | }
93 |
94 | return sum;
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/App.Problems.DigitalTrees/App.Problems.DigitalTrees.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {948164B7-4F99-4AAB-BCCE-11A4575CE3AE}
8 | Exe
9 | App.Problems.DigitalTrees
10 | App.Problems.DigitalTrees
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/App.Problems.GraphRoadTrip.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1CB5F543-2C73-48BB-BD4A-C632F743E594}
8 | Exe
9 | Apps.Problems.GraphRoadTrip
10 | Apps.Problems.GraphRoadTrip
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/App.Problems.Enumerators/App.Problems.Enumerators.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}
8 | Exe
9 | App.Problems.Enumerators.cs
10 | App.Problems.Enumerators.cs
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/App.Problems.TicTacToe.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {21FC4B75-5D20-4BD2-A806-5B8970100BE6}
8 | Exe
9 | App.Problems.TicTacToe
10 | App.Problems.TicTacToe
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/App.Algorithms.15.04.LCS/App.Algorithms.15.04.LCS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}
8 | Exe
9 | App.Algorithms._15._04.LCS
10 | App.Algorithms.15.04.LCS
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/App.Problems.BinaryTreeIterator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {EBF8B214-F389-4797-914E-DFBF1E99B003}
8 | Exe
9 | App.Problems.BinaryTreeIterator
10 | App.Problems.BinaryTreeIterator
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/App.Algorithms.15.01.RodCutting/App.Algorithms.15.01.RodCutting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}
8 | Exe
9 | App.Algorithms._15._01.RodCutting
10 | App.Algorithms.15.01.RodCutting
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/App.Algorithms.04.01.MaxSubarray/App.Algorithms.04.01.MaxSubarray.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}
8 | Exe
9 | App.Algorithms.MaxSubarray
10 | App.Algorithms.04.01.MaxSubarray
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/DigitalTree.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace App.Problems.BoggleWords
7 | {
8 | public class DigitalTree : IEnumerable
9 | {
10 | public DigitalTree()
11 | {
12 | RootNode = new DigitalTreeNode();
13 | }
14 |
15 | public DigitalTreeNode RootNode { get; private set; }
16 |
17 | private void LoadWord(string word)
18 | {
19 | DigitalTreeNode currNode, newNode;
20 |
21 | var upperWord = word.ToUpper();
22 | currNode = RootNode;
23 |
24 | foreach (char ch in upperWord)
25 | {
26 | if (currNode.NextNodes.ContainsKey(ch))
27 | currNode = currNode.NextNodes[ch];
28 | else
29 | {
30 | newNode = new DigitalTreeNode();
31 | currNode.NextNodes.Add(ch, newNode);
32 | currNode = newNode;
33 | }
34 | }
35 |
36 | currNode.IsCompleteWord = true;
37 | }
38 |
39 | public void LoadWords(string[] words)
40 | {
41 | foreach (string word in words)
42 | LoadWord(word);
43 | }
44 |
45 | public void LoadWords(Stream wordStream)
46 | {
47 | using (var reader = new StreamReader(wordStream))
48 | {
49 | string line;
50 |
51 | while ((line = reader.ReadLine()) != null)
52 | LoadWord(line.Trim());
53 | }
54 | }
55 |
56 | public bool ContainsWord(string word)
57 | {
58 | DigitalTreeNode currNode = RootNode;
59 |
60 | foreach (char ch in word)
61 | {
62 | if (!currNode.NextNodes.ContainsKey(ch))
63 | return false;
64 |
65 | currNode = currNode.NextNodes[ch];
66 | }
67 |
68 | return (currNode == null) ? false : currNode.IsCompleteWord;
69 | }
70 |
71 | private IEnumerable InnerEnumerator(DigitalTreeNode currNode, StringBuilder prefix)
72 | {
73 | if (currNode.IsCompleteWord)
74 | yield return prefix.ToString();
75 |
76 | foreach (char ch in currNode.NextNodes.Keys)
77 | {
78 | prefix.Append(ch);
79 |
80 | foreach (string word in InnerEnumerator(currNode.NextNodes[ch], prefix))
81 | yield return word;
82 |
83 | prefix.Remove(prefix.Length - 1, 1);
84 | }
85 | }
86 |
87 | private IEnumerator InnerEnumerator()
88 | {
89 | var prefix = new StringBuilder();
90 |
91 | foreach (string word in InnerEnumerator(RootNode, prefix))
92 | yield return word;
93 | }
94 |
95 | IEnumerator IEnumerable.GetEnumerator()
96 | {
97 | return this.InnerEnumerator();
98 | }
99 |
100 | IEnumerator IEnumerable.GetEnumerator()
101 | {
102 | return this.InnerEnumerator();
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/App.Problems.BoggleWords.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CD373A4E-FD7F-4290-9F6B-F78791E30626}
8 | Exe
9 | App.Problems.BoggleWords
10 | App.Problems.BoggleWords
11 | v4.6.1
12 | 512
13 | true
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/App.Problems.NumberToEnglish/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.NumberToEnglish
4 | {
5 | class Program
6 | {
7 | static void PrintRange(int low, int high)
8 | {
9 | Console.WriteLine();
10 | Console.WriteLine("Values from {0} to {1}:", low, high);
11 |
12 | for (int x = low; x <= high; x++)
13 | Console.WriteLine("{0} = '{1}'", x, EnglishNumberConverter.Convert(x));
14 | }
15 |
16 | static void PrintValue(int val)
17 | {
18 | Console.WriteLine("{0} = '{1}'", val, EnglishNumberConverter.Convert(val));
19 | }
20 |
21 | static void TestValue(int val, string expected)
22 | {
23 | string result = EnglishNumberConverter.Convert(val);
24 |
25 | if (result != expected)
26 | {
27 | Console.WriteLine("FAILED at Value: {0}", val);
28 | Console.WriteLine(" Expected: '{0}'", expected);
29 | Console.WriteLine(" Received: '{0}'", result);
30 | }
31 |
32 | Console.WriteLine("PASSED: {0} = '{1}'", val, result);
33 | }
34 | static void Main(string[] args)
35 | {
36 | PrintRange(0, 20);
37 | PrintRange(95, 105);
38 | PrintRange(995, 1010);
39 |
40 | Console.WriteLine();
41 | Console.WriteLine("Some Edge Cases");
42 | Console.WriteLine("---------------");
43 | PrintValue(Int32.MaxValue);
44 | PrintValue(Int32.MinValue + 1);
45 |
46 | Console.WriteLine();
47 | Console.WriteLine("Some Random Values");
48 | Console.WriteLine("------------------");
49 | var rng = new Random(0);
50 |
51 | for (int x = 0; x < 10; x++)
52 | PrintValue(rng.Next(10, 100));
53 |
54 | for (int x = 0; x < 10; x++)
55 | PrintValue(rng.Next(995, 1999));
56 |
57 | for (int x = 0; x < 10; x++)
58 | PrintValue(rng.Next(999950, 1500000));
59 |
60 | Console.WriteLine();
61 | Console.WriteLine("Testing Values");
62 | Console.WriteLine("--------------");
63 | TestValue(0, "Zero");
64 | TestValue(10, "Ten");
65 | TestValue(15, "Fifteen");
66 | TestValue(99, "Ninety Nine");
67 | TestValue(101, "One Hundred One");
68 | TestValue(999, "Nine Hundred Ninety Nine");
69 | TestValue(1000, "One Thousand");
70 | TestValue(1001, "One Thousand One");
71 | TestValue(9999, "Nine Thousand Nine Hundred Ninety Nine");
72 | TestValue(567891, "Five Hundred Sixty Seven Thousand Eight Hundred Ninety One");
73 | TestValue(10000, "Ten Thousand");
74 | TestValue(10001, "Ten Thousand One");
75 | TestValue(100000, "One Hundred Thousand");
76 | TestValue(100001, "One Hundred Thousand One");
77 | TestValue(1000000, "One Million");
78 | TestValue(1000001, "One Million One");
79 | TestValue(10000000, "Ten Million");
80 | TestValue(10000001, "Ten Million One");
81 | TestValue(100000000, "One Hundred Million");
82 | TestValue(100000001, "One Hundred Million One");
83 | TestValue(1000000000, "One Billion");
84 | TestValue(1000000001, "One Billion One");
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/App.Problems.BlockSizes/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace App.Problems.BlockSizes
8 | {
9 | class Program
10 | {
11 | static int GetBlocksNeeded(int countNeeded, int blockSize)
12 | {
13 | return (countNeeded + blockSize - 1) / blockSize;
14 | }
15 |
16 | static void Main(string[] args)
17 | {
18 | // This was a portion of a problem from HackerRank that was asked of me in a
19 | // recent online programming challenge.
20 | //
21 | // We need N units of something. The units are dished out in blocks of size M units
22 | // per block. How many blocks are needed to serve the number of units (you might
23 | // have some left over - that's okay).
24 | //
25 | // For example, if you need 7 units, and the block size is 3, you need 3 blocks
26 | // (with 2 unneeded units left over).
27 | //
28 | // The formula is simple enough, but maybe not super obvious ... (N + M - 1) / M
29 | //
30 | // Why? At first we might think it is simply N / M, but that won't correctly account
31 | // for the remainder. For example, if N = 7 and M = 3, we need 3 blocks, but N / M
32 | // (integer division of course) only gives us 2. Next try we think, okay, we might
33 | // need a whole extra block of units, so maybe (N + M) / M is the right answer. But that formula,
34 | // with N = 6 and M = 3, we only need 2 blocks, but (6 + 3) / 3 gives us 3, the wrong
35 | // answer.
36 | //
37 | // So we need one less than a whole block of M units to get the right answer. With
38 | // N = 6 and M = 3, we get (6 + 3 - 1) / 3 = 8 / 3 = 2, which is the correct answer.
39 | //
40 | // Let's try it out ...
41 | //
42 | // Should get the following results:
43 | //
44 | // BLOCK SIZE
45 | // | 1 2 3 4 5 6 7 8 9 10
46 | // ---------------------------------------------------------
47 | // N 0 | 0 0 0 0 0 0 0 0 0 0
48 | // E 1 | 1 1 1 1 1 1 1 1 1 1
49 | // E 2 | 2 1 1 1 1 1 1 1 1 1
50 | // D 3 | 3 2 1 1 1 1 1 1 1 1
51 | // E 4 | 4 2 2 1 1 1 1 1 1 1
52 | // D 5 | 5 3 2 2 1 1 1 1 1 1
53 | // 6 | 6 3 2 2 2 1 1 1 1 1
54 | // 7 | 7 4 3 2 2 2 1 1 1 1
55 | // 8 | 8 4 3 2 2 2 2 1 1 1
56 | // 9 | 9 5 3 3 2 2 2 2 1 1
57 | // 10 | 10 5 4 3 2 2 2 2 2 1
58 |
59 | for (int need=0; need < 20; need++)
60 | {
61 | Console.Write("{0} ", need);
62 |
63 | for (int blockSize = 1; blockSize < 20; blockSize++)
64 | Console.Write("{0} ", GetBlocksNeeded(need, blockSize));
65 |
66 | Console.WriteLine();
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/BetterTicTacToeBoard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.TicTacToe
4 | {
5 | public class BetterTicTacToeBoard
6 | {
7 | public BetterTicTacToeBoard(int size)
8 | {
9 | Size = size;
10 | Cells = new int[size, size];
11 | EraseBoard();
12 | }
13 |
14 | public int Size { get; private set; }
15 |
16 | public int TotalMovesMade { get; private set; }
17 |
18 | public int RemainingMoves => Size * Size - TotalMovesMade;
19 |
20 | private int[,] Cells { get; set; }
21 |
22 | private bool CheckForWinAtRow(int row, int playerId)
23 | {
24 | for (int col = 0; col < Size; col++)
25 | {
26 | if (Cells[row, col] != playerId)
27 | return false;
28 | }
29 |
30 | return true;
31 | }
32 |
33 | private bool CheckForWinAtColumn(int col, int playerId)
34 | {
35 | for (int row = 0; row < Size; row++)
36 | {
37 | if (Cells[row, col] != playerId)
38 | return false;
39 | }
40 |
41 | return true;
42 | }
43 |
44 | private bool IsCellAlongDiagnoal1(int row, int col)
45 | {
46 | return row == col;
47 | }
48 |
49 | private bool IsCellAlongDiagonal2(int row, int col)
50 | {
51 | return row == Size - 1 - col;
52 | }
53 |
54 | private bool CheckForWinAtDiagonal1(int playerId)
55 | {
56 | for (int row = 0; row < Size; row++)
57 | {
58 | if (Cells[row, row] != playerId)
59 | return false;
60 | }
61 |
62 | return true;
63 | }
64 |
65 | private bool CheckForWinAtDiagonal2(int playerId)
66 | {
67 | for (int row = Size - 1; row >= 0; row--)
68 | {
69 | if (Cells[row, Size - 1 - row] != playerId)
70 | return false;
71 | }
72 |
73 | return true;
74 | }
75 |
76 | private bool HasPlayerWonAfterMove(int row, int col, int playerId)
77 | {
78 | // A better algorithm for checking for a win
79 | // O(N) - Only check for wins at the rows, columns, and diaganols
80 | // that correspond to the current move
81 |
82 | return (
83 | CheckForWinAtRow(row, playerId) ||
84 | CheckForWinAtColumn(col, playerId) ||
85 | IsCellAlongDiagnoal1(row, col) && CheckForWinAtDiagonal1(playerId) ||
86 | IsCellAlongDiagonal2(row, col) && CheckForWinAtDiagonal2(playerId)
87 | );
88 | }
89 |
90 | public void EraseBoard()
91 | {
92 | for (int row = 0; row < Size; row++)
93 | {
94 | for (int col = 0; col < Size; col++)
95 | Cells[row, col] = 0;
96 | }
97 |
98 | TotalMovesMade = 0;
99 | }
100 |
101 | public bool MakeMoveAndCheckForWin(int row, int col, int playerId)
102 | {
103 | if (Cells[row, col] != 0)
104 | throw new Exception("The cell is not available");
105 |
106 | if (TotalMovesMade == Size * Size)
107 | throw new Exception("The board is full");
108 |
109 | Cells[row, col] = playerId;
110 | TotalMovesMade++;
111 |
112 | return HasPlayerWonAfterMove(row, col, playerId);
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/App.Problems.PyramidHeight/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace App.Problems.PyramidHeight
5 | {
6 | class Program
7 | {
8 | // A pyramid is similar to a binary tree, except that each node can have
9 | // two parents (except the root). In our example, the value of each node
10 | // represents a height. We wish to calculate the maximum height of the
11 | // pyramid.
12 | //
13 | // For example ...
14 | //
15 | // 3
16 | // / \
17 | // 2 1
18 | // / \ / \
19 | // 5 4 3
20 | //
21 | // The answer is 10 (3 + 2 + 5) = 10.
22 | //
23 | // The 3 other paths give us:
24 | // 3 + 2 + 4 = 9
25 | // 3 + 1 + 4 = 8
26 | // 3 + 1 + 3 = 7
27 | //
28 | // So the maxmimum height is 10, the correct answer.
29 | //
30 | // The pyramid is represented as a two dimensional array. The above pyramid
31 | // is represented as follows:
32 | //
33 | // 3 0 0
34 | // 2 1 0
35 | // 5 4 3
36 | //
37 | // Assume there are no missing nodes. Calculate the maximum height.
38 |
39 | static int GetKeyIndex(int[][] pyramid, int row, int col)
40 | {
41 | int totalCols = pyramid.Length; // Total row and column count are the same
42 |
43 | // Convert the (row, col) coordinate into a single key value we can
44 | // use in the dictionary lookup
45 | return row * totalCols + col;
46 | }
47 |
48 | static int MaxPath(int[][] pyramid, Dictionary maxPaths, int row, int col)
49 | {
50 | // Here we use dynamic programming to keep track of previously computed heights
51 | // so that we don't need to recompute them over and over again.
52 |
53 | int keyIndex = GetKeyIndex(pyramid, row, col);
54 | int colCount = row + 1; // The number of columns in this row
55 |
56 | if (maxPaths.ContainsKey(keyIndex))
57 | return maxPaths[keyIndex];
58 |
59 | if (row >= pyramid.Length)
60 | {
61 | maxPaths.Add(keyIndex, 0);
62 | return 0;
63 | }
64 |
65 | if (row == pyramid.Length - 1)
66 | {
67 | maxPaths.Add(keyIndex, pyramid[row][col]);
68 | return pyramid[row][col];
69 | }
70 |
71 | int left = MaxPath(pyramid, maxPaths, row + 1, col);
72 | int right = MaxPath(pyramid, maxPaths, row + 1, col + 1);
73 | int result = Math.Max(left, right) + pyramid[row][col];
74 |
75 | maxPaths.Add(keyIndex, result);
76 |
77 | return result;
78 | }
79 |
80 | static int MaxPath(int[][] pyramid)
81 | {
82 | return MaxPath(pyramid, new Dictionary(), 0, 0);
83 | }
84 |
85 | static void Main(string[] args)
86 | {
87 | int[][] pyramid1 =
88 | {
89 | new int[] { 3, 0, 0 },
90 | new int[] { 2, 1, 0 },
91 | new int[] { 5, 4, 3 }
92 | };
93 |
94 | Console.WriteLine(MaxPath(pyramid1));
95 |
96 | int[][] pyramid2 =
97 | {
98 | new int[] { 4, 0, 0, 0 },
99 | new int[] { 3, 1, 0, 0 },
100 | new int[] { 2, 7, 3, 0 },
101 | new int[] { 3, 2, 1, 1 }
102 | };
103 |
104 | Console.WriteLine(MaxPath(pyramid2));
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/FastTicTacToeBoard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.TicTacToe
4 | {
5 | class FastTicTacToeBoard
6 | {
7 | public FastTicTacToeBoard(int size)
8 | {
9 | Size = size;
10 | Cells = new int[size, size];
11 | RowCounts = new int[size];
12 | ColumnCounts = new int[size];
13 | EraseBoard();
14 | }
15 |
16 | public int Size { get; private set; }
17 |
18 | public int TotalMovesMade { get; private set; }
19 |
20 | public int RemainingMoves => Size * Size - TotalMovesMade;
21 |
22 | private int[,] Cells { get; set; }
23 |
24 | private int[] RowCounts { get; set; }
25 |
26 | private int[] ColumnCounts { get; set; }
27 |
28 | private int Diagonal1Count { get; set; }
29 |
30 | private int Diagonal2Count { get; set; }
31 |
32 | public void EraseBoard()
33 | {
34 | for (int row = 0; row < Size; row++)
35 | {
36 | for (int col = 0; col < Size; col++)
37 | Cells[row, col] = 0;
38 | }
39 |
40 | for (int row = 0; row < Size; row++)
41 | RowCounts[row] = 0;
42 |
43 | for (int col = 0; col < Size; col++)
44 | ColumnCounts[col] = 0;
45 |
46 | Diagonal1Count = 0;
47 | Diagonal2Count = 0;
48 | TotalMovesMade = 0;
49 | }
50 |
51 | private bool IsCellAlongDiagnoal1(int row, int col)
52 | {
53 | return row == col;
54 | }
55 |
56 | private bool IsCellAlongDiagonal2(int row, int col)
57 | {
58 | return row == Size - 1 - col;
59 | }
60 |
61 | private bool CheckForWinAtRow(int row)
62 | {
63 | return Math.Abs(RowCounts[row]) == Size;
64 | }
65 |
66 | private bool CheckForWinAtColumn(int col)
67 | {
68 | return Math.Abs(ColumnCounts[col]) == Size;
69 | }
70 |
71 | private bool CheckForWinAtDiagonal1()
72 | {
73 | return Math.Abs(Diagonal1Count) == Size;
74 | }
75 |
76 | private bool CheckForWinAtDiagonal2()
77 | {
78 | return Math.Abs(Diagonal2Count) == Size;
79 | }
80 |
81 | private bool HasPlayerWonAfterMove(int row, int col)
82 | {
83 | // Fast algorithm for checking for a win
84 | // O(1) - Only check to see if the counters indicate a win. Don't
85 | // need to re-scan every cell
86 |
87 | return (
88 | CheckForWinAtRow(row) ||
89 | CheckForWinAtColumn(col) ||
90 | CheckForWinAtDiagonal1() ||
91 | CheckForWinAtDiagonal2()
92 | );
93 | }
94 |
95 | public bool MakeMoveAndCheckForWin(int row, int col, int playerId)
96 | {
97 | if (Cells[row, col] != 0)
98 | throw new Exception("The cell is not available");
99 |
100 | if (TotalMovesMade == Size * Size)
101 | throw new Exception("The board is full");
102 |
103 | Cells[row, col] = playerId;
104 |
105 | int increment = (playerId == 1) ? 1 : -1;
106 | RowCounts[row] += increment;
107 | ColumnCounts[col] += increment;
108 |
109 | if (IsCellAlongDiagnoal1(row, col))
110 | Diagonal1Count += increment;
111 |
112 | if (IsCellAlongDiagonal2(row, col))
113 | Diagonal2Count += increment;
114 |
115 | TotalMovesMade++;
116 |
117 | return HasPlayerWonAfterMove(row, col);
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/App.Problems.SnakesAndLadders/SnakesAndLaddersBoard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace App.Problems.SnakesAndLadders
6 | {
7 | public class SnakesAndLaddersBoard
8 | {
9 | public SnakesAndLaddersBoard(int size, int [,] input)
10 | {
11 | Size = size;
12 | Input = input;
13 | }
14 |
15 | public int Size { get; }
16 |
17 | public int[,] Input { get; }
18 |
19 | private (int, int) GetRowAndColumn(int cellNo)
20 | {
21 | int row = Size - (cellNo - 1) / Size - 1;
22 | int rowOffset = (cellNo - 1) / Size;
23 | int offset = (cellNo - 1) % Size;
24 | int column = (rowOffset % 2 == 0) ? offset : Size - offset - 1;
25 |
26 | return (row, column);
27 | }
28 |
29 | private Dictionary> ScanCells()
30 | {
31 | var result = new Dictionary>();
32 |
33 | for (int cellNo=1; cellNo <= Size * Size; cellNo++)
34 | {
35 | (int row, int col) = GetRowAndColumn(cellNo);
36 |
37 | if (Input[row, col] != -1)
38 | {
39 | int indirectCellNo = Input[row, col];
40 | List list = null;
41 |
42 | if (result.ContainsKey(indirectCellNo))
43 | list = result[indirectCellNo];
44 | else
45 | {
46 | list = new List();
47 | result.Add(indirectCellNo, list);
48 | }
49 |
50 | list.Add(cellNo);
51 | }
52 | }
53 |
54 | return result;
55 | }
56 |
57 | public int Solve(Dictionary> scanned, HashSet currentSearch, Dictionary saved, int cellNo)
58 | {
59 | if (saved.ContainsKey(cellNo))
60 | return saved[cellNo];
61 |
62 | if (cellNo == 1)
63 | {
64 | saved.Add(1, 0);
65 | return 0;
66 | }
67 |
68 | currentSearch.Add(cellNo);
69 |
70 | bool hasSolution = false;
71 | int min = Int32.MaxValue;
72 |
73 | if (scanned.ContainsKey(cellNo))
74 | {
75 | foreach (int indirectCellNo in scanned[cellNo])
76 | {
77 | if (!currentSearch.Contains(indirectCellNo))
78 | {
79 | int currResult = Solve(scanned, currentSearch, saved, indirectCellNo);
80 | if (currResult != -1 && currResult < min)
81 | {
82 | hasSolution = true;
83 | min = currResult;
84 | }
85 | }
86 | }
87 | }
88 |
89 | for (int prevCellNo=cellNo-1; prevCellNo > cellNo - 1 - Size && prevCellNo > 0; prevCellNo--)
90 | {
91 | (int currRow, int currColumn) = GetRowAndColumn(prevCellNo);
92 |
93 | if (Input[currRow, currColumn] == -1 && !currentSearch.Contains(prevCellNo))
94 | {
95 | int currResult = Solve(scanned, currentSearch, saved, prevCellNo);
96 | if (currResult != -1 && currResult + 1 < min)
97 | {
98 | hasSolution = true;
99 | min = currResult + 1;
100 | }
101 | }
102 | }
103 |
104 | int result = hasSolution ? min : -1;
105 | saved.Add(cellNo, result);
106 | currentSearch.Remove(cellNo);
107 |
108 | return result;
109 | }
110 |
111 | public int Solve()
112 | {
113 | return Solve(ScanCells(), new HashSet(), new Dictionary(), Size * Size);
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace App.Problems.BinaryTreeIterator
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | // This program shows how to iterate over a binary tree with a non-recursive algorithm.
11 | // The main idea is to show how to write GetNextNode() and GetPrevNode() without the
12 | // benefit of recursion. In a recursive algorithm, the runtime stack keeps some important
13 | // contextual information for us. With a non-recursive algorithm, we don't have the benefit
14 | // of the stack, so we have to do a little more work. See the implementations of
15 | // BinaryTree.GetNextNode() and BinaryTree.GetPrevNode().
16 |
17 | var tree = new BinaryTree(StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, false));
18 |
19 | // Note: My Insert() algorithm doesn't guarantee the tree is balanced, but that's not important
20 | // for the purpose of this exercise. I'm merely trying to demonstrate that GetNextNode() and
21 | // GetPrevNode() work as expected.
22 | //
23 | // The nodes are inserted in sorted order.
24 |
25 | tree.Insert("One");
26 | tree.Insert("Two");
27 | tree.Insert("Three");
28 | tree.Insert("Four");
29 | tree.Insert("Five");
30 | tree.Insert("Kevin");
31 | tree.Insert("Alias");
32 | tree.Insert("Heavy");
33 | tree.Insert("Murky");
34 | tree.Insert("Added");
35 | tree.Insert("Birch");
36 | tree.Insert("Viva");
37 | tree.Insert("Money");
38 |
39 | Console.WriteLine("Iterate Forwards Through Tree");
40 | Console.WriteLine("-----------------------------");
41 |
42 | var node = tree.GetFirstNode();
43 |
44 | while (node != null)
45 | {
46 | Console.WriteLine(node.Data);
47 | node = tree.GetNextNode(node);
48 | }
49 |
50 | Console.WriteLine();
51 | Console.WriteLine("Iterate Backwards Through Tree");
52 | Console.WriteLine("------------------------------");
53 |
54 | node = tree.GetLastNode();
55 |
56 | while (node != null)
57 | {
58 | Console.WriteLine(node.Data);
59 | node = tree.GetPrevNode(node);
60 | }
61 |
62 | Console.WriteLine();
63 | Console.WriteLine("Iterate Through Tree with Recursive Iterator using yield return");
64 | Console.WriteLine("---------------------------------------------------------------");
65 |
66 | var recursiveWrapper = new RecursivelyEnumerableBinaryTreeWrapper(tree);
67 |
68 | foreach (string val in recursiveWrapper)
69 | Console.WriteLine(val);
70 |
71 | // Using the enumerator's MoveNext() method, we're essentially accomplishing the same
72 | // thing as the non-recursive version of GetNextNode(). In most languages, it isn't
73 | // possible to implement a recursive, manually-controllable enumerator because we need
74 | // a way of returning the next result back to the caller. However, using C#'s
75 | // "yield return" technique, we can accomplish this in an elegant way.
76 |
77 | var enumerator = (recursiveWrapper as IEnumerable).GetEnumerator();
78 |
79 | Console.WriteLine();
80 | Console.WriteLine("Calling the Enumerator methods manually (without foreach)");
81 | Console.WriteLine("---------------------------------------------------------");
82 |
83 | while (enumerator.MoveNext())
84 | Console.WriteLine(enumerator.Current);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/App.Problems.TicTacToe/SlowTicTacToeBoard.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.TicTacToe
4 | {
5 | public class SlowTicTacToeBoard
6 | {
7 | public SlowTicTacToeBoard(int size)
8 | {
9 | Size = size;
10 | Cells = new int[size, size];
11 | EraseBoard();
12 | }
13 |
14 | public int Size { get; private set; }
15 |
16 | public int TotalMovesMade { get; private set; }
17 |
18 | public int RemainingMoves => Size * Size - TotalMovesMade;
19 |
20 | private int[,] Cells { get; set; }
21 |
22 | private bool CheckForWinAtRow(int row, int playerId)
23 | {
24 | for (int col = 0; col < Size; col++)
25 | {
26 | if (Cells[row, col] != playerId)
27 | return false;
28 | }
29 |
30 | return true;
31 | }
32 |
33 | private bool CheckForWinAtColumn(int col, int playerId)
34 | {
35 | for (int row = 0; row < Size; row++)
36 | {
37 | if (Cells[row, col] != playerId)
38 | return false;
39 | }
40 |
41 | return true;
42 | }
43 |
44 | private bool IsCellAlongDiagnoal1(int row, int col)
45 | {
46 | return row == col;
47 | }
48 |
49 | private bool IsCellAlongDiagonal2(int row, int col)
50 | {
51 | return row == Size - 1 - col;
52 | }
53 |
54 | private bool CheckForWinAtDiagonal1(int playerId)
55 | {
56 | for (int row = 0; row < Size; row++)
57 | {
58 | if (Cells[row, row] != playerId)
59 | return false;
60 | }
61 |
62 | return true;
63 | }
64 |
65 | private bool CheckForWinAtDiagonal2(int playerId)
66 | {
67 | for (int row = Size - 1; row >= 0; row--)
68 | {
69 | if (Cells[row, Size - 1 - row] != playerId)
70 | return false;
71 | }
72 |
73 | return true;
74 | }
75 |
76 | private bool CheckForWinAtAllRows(int playerId)
77 | {
78 | // Scan each row
79 | for (int currRow = 0; currRow < Size; currRow++)
80 | {
81 | if (CheckForWinAtRow(currRow, playerId))
82 | return true;
83 | }
84 |
85 | return false;
86 | }
87 |
88 | private bool CheckForWinAtAllColumns(int playerId)
89 | {
90 | // Scan each column
91 | for (int currCol = 0; currCol < Size; currCol++)
92 | {
93 | if (CheckForWinAtColumn(currCol, playerId))
94 | return true;
95 | }
96 |
97 | return false;
98 | }
99 |
100 | private bool HasPlayerWon(int playerId)
101 | {
102 | // Slow O(N^2) algorithm
103 | // Re-scan all rows, columns, and diagonals
104 |
105 | return (
106 | CheckForWinAtAllRows(playerId) ||
107 | CheckForWinAtAllColumns(playerId) ||
108 | CheckForWinAtDiagonal1(playerId) ||
109 | CheckForWinAtDiagonal2(playerId)
110 | );
111 | }
112 |
113 | public void EraseBoard()
114 | {
115 | for (int row = 0; row < Size; row++)
116 | {
117 | for (int col = 0; col < Size; col++)
118 | Cells[row, col] = 0;
119 | }
120 |
121 | TotalMovesMade = 0;
122 | }
123 |
124 | public bool MakeMoveAndCheckForWin(int row, int col, int playerId)
125 | {
126 | if (Cells[row, col] != 0)
127 | throw new Exception("The cell is not available");
128 |
129 | if (TotalMovesMade == Size * Size)
130 | throw new Exception("The board is full");
131 |
132 | Cells[row, col] = playerId;
133 | TotalMovesMade++;
134 |
135 | return HasPlayerWon(playerId);
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/App.Problems.GraphRoadTrip/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace App.Problems.GraphRoadTrip
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | // Given a bi-directionally linked graph of nodes, where each node represents
10 | // a location with a population, consider the case where the entire population
11 | // must travel on a road trip to visit a given node. Nodes must travel through
12 | // their neighbors to get to the ultimate destination. For any given node, find
13 | // which neighbor will be bringing the largest population, and the magnitude
14 | // that neighbor is bringing. There are no cycles in the graph.
15 | //
16 | // Example: In the below example, if everyone needs to travel to Denver, then
17 | // 6 people are coming from Cheyenne, 15 are coming from Santa Fe (the 7 in
18 | // Santa Fe itself, plush 3 from Las Cruce and 5 from Albuquerque), and 11 are
19 | // coming from Topeka. So the answer would be (Santa Fe, 15) because that is the
20 | // neighbor delivering the largest magnitude.
21 | //
22 | // Similarly, if everyone needs to travel to Santa Fe, then the answer would be
23 | // (Denver, 29).
24 | //
25 | // Assume the graph is large and the question may be posed repeatedly (i.e., think
26 | // about ways to maximize performance).
27 |
28 | var graph = new Graph();
29 |
30 | var denver = new Node() { Name = "Denver", Population = 12 };
31 | var cheyenne = new Node { Name = "Cheyenne", Population = 6 };
32 | var santafe = new Node() { Name = "Santa Fe", Population = 7 };
33 | var lascruces = new Node { Name = "Las Cruces", Population = 3 };
34 | var albuquerque = new Node() { Name = "Albuquerque", Population = 5 };
35 | var topeka = new Node() { Name = "Topeka", Population = 8 };
36 | var columbia = new Node() { Name = "Columbia", Population = 1 };
37 | var beatrice = new Node() { Name = "Beatrice", Population = 2 };
38 |
39 | denver.Neighbors.Add(cheyenne);
40 | denver.Neighbors.Add(santafe);
41 | denver.Neighbors.Add(topeka);
42 |
43 | cheyenne.Neighbors.Add(denver);
44 |
45 | santafe.Neighbors.Add(denver);
46 | santafe.Neighbors.Add(lascruces);
47 | santafe.Neighbors.Add(albuquerque);
48 |
49 | lascruces.Neighbors.Add(santafe);
50 | albuquerque.Neighbors.Add(santafe);
51 |
52 | topeka.Neighbors.Add(denver);
53 | topeka.Neighbors.Add(columbia);
54 | topeka.Neighbors.Add(beatrice);
55 |
56 | columbia.Neighbors.Add(topeka);
57 | beatrice.Neighbors.Add(topeka);
58 |
59 | graph.Nodes.Add(denver);
60 | graph.Nodes.Add(cheyenne);
61 | graph.Nodes.Add(santafe);
62 | graph.Nodes.Add(lascruces);
63 | graph.Nodes.Add(albuquerque);
64 | graph.Nodes.Add(topeka);
65 | graph.Nodes.Add(columbia);
66 | graph.Nodes.Add(beatrice);
67 |
68 | RoadTripMagnitudeResult result = null;
69 |
70 | Console.WriteLine("Travel to Denver");
71 | result = graph.GetRoadTripMagnitude(denver);
72 | Console.WriteLine(result.Node.Name);
73 | Console.WriteLine(result.Magnitude);
74 | Console.WriteLine();
75 |
76 | Console.WriteLine("Travel to Cheyenne");
77 | result = graph.GetRoadTripMagnitude(cheyenne);
78 | Console.WriteLine(result.Node.Name);
79 | Console.WriteLine(result.Magnitude);
80 | Console.WriteLine();
81 |
82 | Console.WriteLine("Travel to Santa Fe");
83 | result = graph.GetRoadTripMagnitude(santafe);
84 | Console.WriteLine(result.Node.Name);
85 | Console.WriteLine(result.Magnitude);
86 | Console.WriteLine();
87 |
88 | Console.WriteLine("Travel to Topeka");
89 | result = graph.GetRoadTripMagnitude(topeka);
90 | Console.WriteLine(result.Node.Name);
91 | Console.WriteLine(result.Magnitude);
92 | Console.WriteLine();
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/App.Problems.BinaryTreeIterator/BinaryTree.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.BinaryTreeIterator
4 | {
5 | public class BinaryTree
6 | {
7 | public BinaryTree(IComparer comparer)
8 | {
9 | Comparer = comparer;
10 | }
11 |
12 | public IComparer Comparer { get; private set; }
13 |
14 | public BinaryTreeNode RootNode { get; private set; }
15 |
16 | private BinaryTreeNode GetFirstNodeInSubtree(BinaryTreeNode baseNode)
17 | {
18 | if (baseNode == null)
19 | return null;
20 |
21 | var result = baseNode;
22 |
23 | while (result.LeftNode != null)
24 | result = result.LeftNode;
25 |
26 | return result;
27 | }
28 |
29 | private BinaryTreeNode GetLastNodeInSubtree(BinaryTreeNode baseNode)
30 | {
31 | if (baseNode == null)
32 | return null;
33 |
34 | var result = baseNode;
35 |
36 | while (result.RightNode != null)
37 | result = result.RightNode;
38 |
39 | return result;
40 | }
41 |
42 | public BinaryTreeNode Insert(TData val)
43 | {
44 | if (RootNode == null)
45 | {
46 | RootNode = new BinaryTreeNode();
47 | RootNode.Data = val;
48 |
49 | return RootNode;
50 | }
51 |
52 | var baseNode = FindClosestNode(RootNode, val);
53 | var newNode = new BinaryTreeNode();
54 |
55 | newNode.Data = val;
56 | newNode.ParentNode = baseNode;
57 |
58 | if (Comparer.Compare(baseNode.Data, val) > 0)
59 | {
60 | newNode.LeftNode = baseNode.LeftNode;
61 | baseNode.LeftNode = newNode;
62 | }
63 | else
64 | {
65 | newNode.RightNode = baseNode.RightNode;
66 | baseNode.RightNode = newNode;
67 | }
68 |
69 | return newNode;
70 | }
71 |
72 | public BinaryTreeNode FindClosestNode(BinaryTreeNode baseNode, TData val)
73 | {
74 | if (baseNode == null)
75 | return null;
76 |
77 | if (Comparer.Compare(baseNode.Data, val) > 0)
78 | return (baseNode.LeftNode != null) ? FindClosestNode(baseNode.LeftNode, val) : baseNode;
79 |
80 | return (baseNode.RightNode != null) ? FindClosestNode(baseNode.RightNode, val) : baseNode;
81 | }
82 |
83 | public BinaryTreeNode GetFirstNode()
84 | {
85 | return GetFirstNodeInSubtree(RootNode);
86 | }
87 |
88 | public BinaryTreeNode GetLastNode()
89 | {
90 | return GetLastNodeInSubtree(RootNode);
91 | }
92 |
93 | public BinaryTreeNode GetNextNode(BinaryTreeNode currentNode)
94 | {
95 | if (currentNode == null)
96 | return null;
97 |
98 | if (currentNode.RightNode != null)
99 | return GetFirstNodeInSubtree(currentNode.RightNode);
100 |
101 | var result = currentNode;
102 |
103 | // This is the trick to a non-recursive binary tree iterator. If the current node is on
104 | // the right hand side of the parent node, then we need to keep going up the chain until
105 | // we're on the left hand side, or we reach the root. Then, the next node is the parent.
106 | while (result != null && result.ParentNode != null && result.ParentNode.RightNode == result)
107 | result = result.ParentNode;
108 |
109 | return (result == null) ? result : result.ParentNode;
110 | }
111 |
112 | public BinaryTreeNode GetPrevNode(BinaryTreeNode currentNode)
113 | {
114 | if (currentNode == null)
115 | return null;
116 |
117 | if (currentNode.LeftNode != null)
118 | return GetLastNodeInSubtree(currentNode.LeftNode);
119 |
120 | var result = currentNode;
121 |
122 | // Same technique as used for GetNextNode(), except this time we check if we're on the left hand side
123 | while (result != null && result.ParentNode != null && result.ParentNode.LeftNode == result)
124 | result = result.ParentNode;
125 |
126 | return (result == null) ? result : result.ParentNode;
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/App.Problems.NumberToEnglish/EnglishNumberConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace App.Problems.NumberToEnglish
5 | {
6 | public class EnglishNumberConverter
7 | {
8 | private static int GetHundredsValue(int val) => val / 100;
9 |
10 | private static int GetTensValue(int val) => (val % 100) / 10;
11 |
12 | private static int GetOnesValue(int val) => val % 10;
13 |
14 | private static string GetDigitText(int val)
15 | {
16 | switch (val)
17 | {
18 | case 0: return String.Empty;
19 | case 1: return "One";
20 | case 2: return "Two";
21 | case 3: return "Three";
22 | case 4: return "Four";
23 | case 5: return "Five";
24 | case 6: return "Six";
25 | case 7: return "Seven";
26 | case 8: return "Eight";
27 | case 9: return "Nine";
28 | default: throw new ArgumentOutOfRangeException();
29 | }
30 | }
31 |
32 | private static string GetTweenerText(int val)
33 | {
34 | switch (val)
35 | {
36 | case 10: return "Ten";
37 | case 11: return "Eleven";
38 | case 12: return "Twelve";
39 | case 13: return "Thirteen";
40 | case 14: return "Fourteen";
41 | case 15: return "Fifteen";
42 | case 16: return "Sixteen";
43 | case 17: return "Seventeen";
44 | case 18: return "Eighteen";
45 | case 19: return "Nineteen";
46 | default: throw new ArgumentOutOfRangeException();
47 | }
48 | }
49 |
50 | private static string GetTensText(int val)
51 | {
52 | switch (val)
53 | {
54 | case 1: return "Ten";
55 | case 2: return "Twenty";
56 | case 3: return "Thirty";
57 | case 4: return "Forty";
58 | case 5: return "Fifty";
59 | case 6: return "Sixty";
60 | case 7: return "Seventy";
61 | case 8: return "Eighty";
62 | case 9: return "Ninety";
63 | default: throw new ArgumentOutOfRangeException();
64 | }
65 | }
66 |
67 | private static string GetThousandsSuffix(int thousandsCounter)
68 | {
69 | switch (thousandsCounter)
70 | {
71 | case 0: return "";
72 | case 1: return " Thousand";
73 | case 2: return " Million";
74 | case 3: return " Billion";
75 | default: throw new ArgumentOutOfRangeException();
76 | }
77 | }
78 |
79 | private static void AppendThousandsValueText(int val, StringBuilder output)
80 | {
81 | // Handle numbers from 0 to 999
82 |
83 | if (val < 0 || val >= 1000)
84 | throw new ArgumentOutOfRangeException();
85 |
86 | if (val >= 0 && val < 10)
87 | {
88 | // Handle 0 - 9
89 | output.Append(GetDigitText(val));
90 | }
91 | else if (val >= 10 && val < 20)
92 | {
93 | // Handle 10 - 19
94 | output.Append(GetTweenerText(val));
95 | }
96 | else if (val >= 20 && val < 100)
97 | {
98 | // Handle 20 - 99
99 | int tensVal = GetTensValue(val);
100 | int onesVal = GetOnesValue(val);
101 |
102 | output.Append(GetTensText(tensVal));
103 |
104 | if (onesVal > 0)
105 | {
106 | output.Append(" ");
107 | output.Append(GetDigitText(onesVal));
108 | }
109 | }
110 | else if (val >= 100 && val < 1000)
111 | {
112 | // Handle 100 - 999
113 | int hundredsVal = GetHundredsValue(val);
114 | int remainderVal = val % 100;
115 |
116 | output.Append(GetDigitText(hundredsVal));
117 | output.Append(" Hundred");
118 |
119 | if (remainderVal > 0)
120 | {
121 | output.Append(" ");
122 | AppendThousandsValueText(remainderVal, output);
123 | }
124 | }
125 | }
126 |
127 | private static void AppendValueText(int origVal, int currVal, int thousandsCounter, StringBuilder output)
128 | {
129 | if (origVal == 0)
130 | {
131 | // Handle special case: Zero
132 | output.Append("Zero");
133 | return;
134 | }
135 |
136 | if (origVal < 0)
137 | {
138 | output.Append("Negative ");
139 | AppendValueText(-origVal, -currVal, thousandsCounter, output);
140 | return;
141 | }
142 |
143 | int currThousandsVal = currVal % 1000;
144 | int nextVal = currVal / 1000;
145 |
146 | if (nextVal > 0)
147 | AppendValueText(origVal, nextVal, thousandsCounter + 1, output);
148 |
149 | if (currThousandsVal > 0)
150 | {
151 | if (nextVal > 0)
152 | output.Append(" ");
153 |
154 | AppendThousandsValueText(currThousandsVal, output);
155 | output.Append(GetThousandsSuffix(thousandsCounter));
156 | }
157 | }
158 |
159 | public static string Convert(int val)
160 | {
161 | var output = new StringBuilder();
162 | AppendValueText(val, val, 0, output);
163 |
164 | return output.ToString();
165 | }
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/App.Problems.BoggleWords/BoggleWordFinder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace App.Problems.BoggleWords
4 | {
5 | class BoggleWordFinder
6 | {
7 | public BoggleWordFinder(BoggleBoard boggleBoard, WordDictionary wordDictionary)
8 | {
9 | BoggleBoard = boggleBoard;
10 | WordDictionary = wordDictionary;
11 | MinimumWordLength = 3;
12 | }
13 |
14 | public BoggleBoard BoggleBoard { get; private set; }
15 |
16 | public WordDictionary WordDictionary { get; private set; }
17 |
18 | public int MinimumWordLength { get; set; }
19 |
20 | private int GetIndex(int row, int col)
21 | {
22 | return row * BoggleBoard.ColumnCount + col;
23 | }
24 |
25 | private int GetRow(int index)
26 | {
27 | return index / BoggleBoard.ColumnCount;
28 | }
29 |
30 | private int GetColumn(int index)
31 | {
32 | return index % BoggleBoard.ColumnCount;
33 | }
34 |
35 | private bool IsLegalCell(int row, int col)
36 | {
37 | return (
38 | row >= 0 &&
39 | row < BoggleBoard.RowCount &&
40 | col >= 0 &&
41 | col < BoggleBoard.ColumnCount
42 | );
43 | }
44 |
45 | private IEnumerable GetNeighbors(int row, int col)
46 | {
47 | if (IsLegalCell(row - 1, col - 1)) yield return GetIndex(row - 1, col - 1);
48 | if (IsLegalCell(row - 1, col)) yield return GetIndex(row - 1, col);
49 | if (IsLegalCell(row - 1, col + 1)) yield return GetIndex(row - 1, col + 1);
50 | if (IsLegalCell(row, col - 1)) yield return GetIndex(row, col - 1);
51 | if (IsLegalCell(row, col + 1)) yield return GetIndex(row, col + 1);
52 | if (IsLegalCell(row + 1, col - 1)) yield return GetIndex(row + 1, col - 1);
53 | if (IsLegalCell(row + 1, col)) yield return GetIndex(row + 1, col);
54 | if (IsLegalCell(row + 1, col + 1)) yield return GetIndex(row + 1, col + 1);
55 | }
56 |
57 | private void AddPathToList(List> list, List path)
58 | {
59 | var newPath = new List();
60 |
61 | foreach (var node in path)
62 | {
63 | var newNode = new WordPathNode(node.Row, node.Column, node.Character);
64 | newPath.Add(newNode);
65 | }
66 |
67 | list.Add(newPath);
68 | }
69 |
70 | public List> FindWords(int currRow, int currCol,
71 | List> results, DigitalTreeNode currNode, List currPath, HashSet visitorTracker, HashSet foundWords)
72 | {
73 | if (currNode.IsCompleteWord && !foundWords.Contains(currNode))
74 | {
75 | if (currPath.Count >= MinimumWordLength)
76 | AddPathToList(results, currPath);
77 |
78 | // Keep track of found words so we don't add duplicates
79 | foundWords.Add(currNode);
80 | }
81 |
82 | foreach (int nextIndex in GetNeighbors(currRow, currCol))
83 | {
84 | if (visitorTracker.Contains(nextIndex))
85 | continue; // We've already visited this node
86 |
87 | int nextRow = GetRow(nextIndex);
88 | int nextCol = GetColumn(nextIndex);
89 | char nextChar = BoggleBoard.GetCharacter(nextRow, nextCol);
90 | DigitalTreeNode nextNode = null;
91 |
92 | if (!currNode.NextNodes.ContainsKey(nextChar))
93 | continue;
94 |
95 | nextNode = currNode.NextNodes[nextChar];
96 | // TODO: Account for the "U" that follows "Q" on the "QU" dices
97 |
98 | currPath.Add(new WordPathNode(nextRow, nextCol, nextChar));
99 | visitorTracker.Add(nextIndex);
100 |
101 | // Recurse into neighbors with viable prefixes
102 | FindWords(GetRow(nextIndex), GetColumn(nextIndex), results, nextNode, currPath, visitorTracker, foundWords);
103 |
104 | visitorTracker.Remove(nextIndex);
105 | currPath.RemoveAt(currPath.Count - 1);
106 | }
107 |
108 | return results;
109 | }
110 |
111 | public List> FindWords()
112 | {
113 | var results = new List>();
114 | var visitorTracker = new HashSet();
115 | var foundWords = new HashSet();
116 |
117 | for (int row=0; row < BoggleBoard.RowCount; row++)
118 | {
119 | for (int col=0; col < BoggleBoard.ColumnCount; col++)
120 | {
121 | var currChar = BoggleBoard.GetCharacter(row, col);
122 | if (!WordDictionary.RootTreeNode.NextNodes.ContainsKey(currChar))
123 | continue;
124 |
125 | var startPath = new List();
126 | startPath.Add(new WordPathNode(row, col, currChar));
127 | visitorTracker.Add(GetIndex(row, col));
128 |
129 | // Find all the words that start with this letter
130 | FindWords(row, col, results, WordDictionary.RootTreeNode.NextNodes[currChar], startPath, visitorTracker, foundWords);
131 |
132 | visitorTracker.Remove(GetIndex(row, col));
133 | }
134 | }
135 |
136 | return results;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | *.mdf
221 | *.ldf
222 | *.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # CodeRush
271 | .cr/
272 |
273 | # Python Tools for Visual Studio (PTVS)
274 | __pycache__/
275 | *.pyc
276 |
277 | # Cake - Uncomment if you are using it
278 | # tools/**
279 | # !tools/packages.config
280 |
281 | # Telerik's JustMock configuration file
282 | *.jmconfig
283 |
284 | # BizTalk build output
285 | *.btp.cs
286 | *.btm.cs
287 | *.odx.cs
288 | *.xsd.cs
289 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Programming Practice
2 | This project was created to help practice for technical interviews. The sample code is written in C#.
3 |
4 | The project generally follows "Introduction to Algorithms", Third Edition (Cormen, Leiserson, Rivest, & Stein), and throws in a few
5 | other programming challenges that have been thrown at me during technical interviews.
6 |
7 | ## Workflow for Tackling a Technical Interview
8 | 1. Ask clarifying questions
9 | 2. Layout sample data with corner cases
10 | 3. Discuss naive/inefficient solution
11 | 4. Find more efficient solution
12 | 5. Design & walk through the solution
13 | 6. Code the solution
14 | 7. Test the solution on the original sample data
15 | 8. Optional: Discuss advanced topics
16 |
17 | * Ask clarifying questions
18 | * Think out loud so the interviewer can learn your thought process
19 | * Resist the temptation to jump directly into coding
20 | * Input ranges?
21 | * Input sizes?
22 | * Type of values in input (integer, floating point, etc.)
23 | * Expected size of data
24 | * Can the input contain zeroes?
25 | * Can the input contain duplicates?
26 | * Performance and memory constraints
27 | * Etc.
28 | * Layout some sample data
29 | * Verify how the solution should behave on some sample data
30 | * Showcase any obvious corner cases with a separate set of sample data
31 | * First Approaches (Probably Not the Best Solution)
32 | * Think of the most naive, brute force method of solving the problem
33 | * It will usually involving comparing every possible permutation of the input data to find a solution
34 | * This will typically be very inefficient - usually O(n^2) or worse
35 | * It's good to get the naive solution on the table, but be sure the interviewer recognizes that you realize its an inefficient solution
36 | * Finding a more efficient solution
37 | * Think of progression in efficiency: O(2^n) -> O(n^2) -> O(n log[n]) -> O(n) -> O(log [n]) -> O(1)
38 | * Try to identify, intuitively, what is most likely the fastest possible solution
39 | * Example: I can see I'm going to need to examine every input, so I know the fastest solution is at least O(n)
40 | * Many interview questions tend to have an obvious O(n^2) solution, and a non-obvious O(n) or O(1) solution. That's *why* it's an interview question.
41 | * How can it be faster?
42 | * Is there a way avoid examining every possible permutation of input data?
43 | * Can you sort or reorganize the input data to make searching faster?
44 | * Is there something about the nature of input data as it relates to the output that can be exploited to avoid looking at all permutations
45 | * Can you use a creative search direction (left-to-right only, right-to-left only, move in from each edge, spiral out from the middle, dovetail down from the corner, etc)
46 | * Can you use lookup tables somehow?
47 | * Are you storing transient state information in the most efficient way?
48 | * Can you pre-compute the answer, then subtract off input values to reach the final solution?
49 | * Algorithmic Methods to consider for a faster/better solution
50 | * Recursion / Divide & Conquer
51 | * Dynamic Programming (divide into subproblems, store results in a table to avoid re-computing subproblems many times)
52 | * Iterative / Bottoms Up Approach - Similar to dynamic programming, but without recursion. Only track the subproblem solutions you actually need, not all of them
53 | * State machines
54 | * Keeping intermediate lookup tables
55 | * Think of similar problems with known algorithms (e.g., "this looks a little bit like rod cutting, so dynamic programming might work")
56 | * For a very advanced technique, map the problem to another known problem, solve it, then reverse the process to get the answer
57 | * For example, the DeRemer and Penello LALR(1) algorithm maps the problem to a Strongly Connected Components problem for a graph
58 | * "This maps to the halting problem, so I know it's unsolvable"
59 | * "This maps to the traveling sales person problem, so I know it's NP-complete"
60 | * If you're still stumped, ask for a hint
61 | * Walk through the solution
62 | * When you think you have an efficient solution, design the solution first, walking through the input data to show how it will work
63 | * Code the solution
64 | * Think about corner cases and try to handle them naturally and elegantly without special-case if statements
65 | * Test the solution
66 | * Walk through the original sample data to show that the solution works
67 | * Advanced topics
68 | * Discuss time/space tradeoffs
69 | * Is the solution thread safe? If not, how can it be extended to be thread safe?
70 | * Does the solution lend itself to parallelization, and if so, how?
71 | * Could the solution be divided and scaled out onto a server farm?
72 |
73 | ## Solution Examples
74 | * Number of bits in a byte - Use a pre-computed lookup table
75 | * Maximum Subarray - Iterative, bottoms-up approach gives an O(n) solution
76 | * Find a pair of values that sum to a given value
77 | * If the values are sorted, move in from each end to find the pair(s)
78 | * If not sorted, sort them -> O(n log[n])
79 | * For a faster, but less space efficient solution - store the number's complement in a lookup table
80 | * Rod Cutting - Text book dynamic programming example
81 | * Longest Common Subsequence - Dynamic programming using a first past to pre-compute a table so we know which direction to search, then a second, recursive pass to find the longest commong subsequence. It's pretty tricky and wouldn't be a very fair interview question in my view.
82 | * Detect a cycle in a graph with single links - Tortoise/Hare - One pointer jumps one segment ahead on each hop, the second "fast" pointer jumps two segments ahead. Another unfair interiew question in my opinion. Unless the interviewee has previously studied the approach, they would be unlikely to come up with it in an impromptu interview session. It's a "gotcha" question that doesn't really prove much about the skills of the candidate.
83 | * Fibonacci - Naive recursive algorithm is O(2^n). An iterative, bottoms-up approach is simple and O(n)
84 | * Palindrome - Pretty easy. Can be solved either with an iterative approach (move in from each edge) or a recusive solution. Both are O(n)
85 | * Tic-Tac-Toe - Maintain a counter for each row, column, and diagonal instead of re-scanning cells each move
86 | * Missing integer in an array - Compute the expected sum with n * (n + 1) / 2. Then iterative over the values and subtract them. The number you have left is the missing integer. Tricky but easy once you know the answer.
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ProgrammingPractice.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2005
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Algorithms.04.01.MaxSubarray", "App.Algorithms.04.01.MaxSubarray\App.Algorithms.04.01.MaxSubarray.csproj", "{9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.Fibonacci", "App.Problems.Fibonacci\App.Problems.Fibonacci.csproj", "{99E4E3E1-F3BB-4547-B734-4172147D51AA}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.BinaryTreeIterator", "App.Problems.BinaryTreeIterator\App.Problems.BinaryTreeIterator.csproj", "{EBF8B214-F389-4797-914E-DFBF1E99B003}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.SpiralIntoMatrix", "App.Problems.SpiralIntoMatrix\App.Problems.SpiralIntoMatrix.csproj", "{38693BC4-9B35-48AF-B785-07792BCCDB2B}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Algorithms.15.04.LCS", "App.Algorithms.15.04.LCS\App.Algorithms.15.04.LCS.csproj", "{55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.Palindrome", "App.Problems.Palindrome\App.Problems.Palindrome.csproj", "{BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Algorithms.15.01.RodCutting", "App.Algorithms.15.01.RodCutting\App.Algorithms.15.01.RodCutting.csproj", "{DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}"
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.BlockSizes", "App.Problems.BlockSizes\App.Problems.BlockSizes.csproj", "{F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.PyramidHeight", "App.Problems.PyramidHeight\App.Problems.PyramidHeight.csproj", "{5F76635A-A9F4-474F-AAB7-B992F4391338}"
23 | EndProject
24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.DigitalTrees", "App.Problems.DigitalTrees\App.Problems.DigitalTrees.csproj", "{948164B7-4F99-4AAB-BCCE-11A4575CE3AE}"
25 | EndProject
26 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.BoggleWords", "App.Problems.BoggleWords\App.Problems.BoggleWords.csproj", "{CD373A4E-FD7F-4290-9F6B-F78791E30626}"
27 | EndProject
28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.PriorityQueue", "App.Problems.PriorityQueue\App.Problems.PriorityQueue.csproj", "{37781CD6-8056-4262-BC70-C5F90E9DF420}"
29 | EndProject
30 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.TicTacToe", "App.Problems.TicTacToe\App.Problems.TicTacToe.csproj", "{21FC4B75-5D20-4BD2-A806-5B8970100BE6}"
31 | EndProject
32 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.ParseTimeFromString", "App.Problems.ParseTimeFromString\App.Problems.ParseTimeFromString.csproj", "{CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}"
33 | EndProject
34 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.GraphRoadTrip", "App.Problems.GraphRoadTrip\App.Problems.GraphRoadTrip.csproj", "{1CB5F543-2C73-48BB-BD4A-C632F743E594}"
35 | EndProject
36 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.Enumerators", "App.Problems.Enumerators\App.Problems.Enumerators.csproj", "{6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}"
37 | EndProject
38 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{89C46CEB-649D-4C5C-A27B-A7237A632AE5}"
39 | ProjectSection(SolutionItems) = preProject
40 | README.md = README.md
41 | EndProjectSection
42 | EndProject
43 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App.Problems.NumberToEnglish", "App.Problems.NumberToEnglish\App.Problems.NumberToEnglish.csproj", "{7C03A5E3-2CB6-42AD-A80D-229EF09E84CB}"
44 | EndProject
45 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App.Problems.RubiksCube", "App.Problems.RubiksCube\App.Problems.RubiksCube.csproj", "{C428373D-B067-47F2-8B71-B7E8D01F6715}"
46 | EndProject
47 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Problems.SnakesAndLadders", "App.Problems.SnakesAndLadders\App.Problems.SnakesAndLadders.csproj", "{F71FD164-2ECD-4E19-842B-BAED269719A4}"
48 | EndProject
49 | Global
50 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
51 | Debug|Any CPU = Debug|Any CPU
52 | Release|Any CPU = Release|Any CPU
53 | EndGlobalSection
54 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
55 | {9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 | {9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 | {9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {9FB8F23A-FDCB-45AC-8950-69CAA2F2BEA4}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {99E4E3E1-F3BB-4547-B734-4172147D51AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
60 | {99E4E3E1-F3BB-4547-B734-4172147D51AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
61 | {99E4E3E1-F3BB-4547-B734-4172147D51AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
62 | {99E4E3E1-F3BB-4547-B734-4172147D51AA}.Release|Any CPU.Build.0 = Release|Any CPU
63 | {EBF8B214-F389-4797-914E-DFBF1E99B003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64 | {EBF8B214-F389-4797-914E-DFBF1E99B003}.Debug|Any CPU.Build.0 = Debug|Any CPU
65 | {EBF8B214-F389-4797-914E-DFBF1E99B003}.Release|Any CPU.ActiveCfg = Release|Any CPU
66 | {EBF8B214-F389-4797-914E-DFBF1E99B003}.Release|Any CPU.Build.0 = Release|Any CPU
67 | {38693BC4-9B35-48AF-B785-07792BCCDB2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68 | {38693BC4-9B35-48AF-B785-07792BCCDB2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
69 | {38693BC4-9B35-48AF-B785-07792BCCDB2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {38693BC4-9B35-48AF-B785-07792BCCDB2B}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72 | {55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}.Debug|Any CPU.Build.0 = Debug|Any CPU
73 | {55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}.Release|Any CPU.ActiveCfg = Release|Any CPU
74 | {55ED5D74-4C5F-4C5B-83A1-4BBCD0588731}.Release|Any CPU.Build.0 = Release|Any CPU
75 | {BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76 | {BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
77 | {BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
78 | {BA89AE5E-567E-47BD-A61E-0C67BC9BD1EF}.Release|Any CPU.Build.0 = Release|Any CPU
79 | {DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
80 | {DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
81 | {DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
82 | {DC4CC736-BA84-4C3D-AAD6-189420D3E5E4}.Release|Any CPU.Build.0 = Release|Any CPU
83 | {F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84 | {F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}.Debug|Any CPU.Build.0 = Debug|Any CPU
85 | {F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}.Release|Any CPU.ActiveCfg = Release|Any CPU
86 | {F63AD16C-F586-4EA6-BF6C-C6856B9D0C61}.Release|Any CPU.Build.0 = Release|Any CPU
87 | {5F76635A-A9F4-474F-AAB7-B992F4391338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88 | {5F76635A-A9F4-474F-AAB7-B992F4391338}.Debug|Any CPU.Build.0 = Debug|Any CPU
89 | {5F76635A-A9F4-474F-AAB7-B992F4391338}.Release|Any CPU.ActiveCfg = Release|Any CPU
90 | {5F76635A-A9F4-474F-AAB7-B992F4391338}.Release|Any CPU.Build.0 = Release|Any CPU
91 | {948164B7-4F99-4AAB-BCCE-11A4575CE3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
92 | {948164B7-4F99-4AAB-BCCE-11A4575CE3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
93 | {948164B7-4F99-4AAB-BCCE-11A4575CE3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
94 | {948164B7-4F99-4AAB-BCCE-11A4575CE3AE}.Release|Any CPU.Build.0 = Release|Any CPU
95 | {CD373A4E-FD7F-4290-9F6B-F78791E30626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
96 | {CD373A4E-FD7F-4290-9F6B-F78791E30626}.Debug|Any CPU.Build.0 = Debug|Any CPU
97 | {CD373A4E-FD7F-4290-9F6B-F78791E30626}.Release|Any CPU.ActiveCfg = Release|Any CPU
98 | {CD373A4E-FD7F-4290-9F6B-F78791E30626}.Release|Any CPU.Build.0 = Release|Any CPU
99 | {37781CD6-8056-4262-BC70-C5F90E9DF420}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
100 | {37781CD6-8056-4262-BC70-C5F90E9DF420}.Debug|Any CPU.Build.0 = Debug|Any CPU
101 | {37781CD6-8056-4262-BC70-C5F90E9DF420}.Release|Any CPU.ActiveCfg = Release|Any CPU
102 | {37781CD6-8056-4262-BC70-C5F90E9DF420}.Release|Any CPU.Build.0 = Release|Any CPU
103 | {21FC4B75-5D20-4BD2-A806-5B8970100BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
104 | {21FC4B75-5D20-4BD2-A806-5B8970100BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
105 | {21FC4B75-5D20-4BD2-A806-5B8970100BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
106 | {21FC4B75-5D20-4BD2-A806-5B8970100BE6}.Release|Any CPU.Build.0 = Release|Any CPU
107 | {CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108 | {CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
109 | {CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
110 | {CB3561A5-FE75-4DF2-A3E4-738E5C182CA6}.Release|Any CPU.Build.0 = Release|Any CPU
111 | {1CB5F543-2C73-48BB-BD4A-C632F743E594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
112 | {1CB5F543-2C73-48BB-BD4A-C632F743E594}.Debug|Any CPU.Build.0 = Debug|Any CPU
113 | {1CB5F543-2C73-48BB-BD4A-C632F743E594}.Release|Any CPU.ActiveCfg = Release|Any CPU
114 | {1CB5F543-2C73-48BB-BD4A-C632F743E594}.Release|Any CPU.Build.0 = Release|Any CPU
115 | {6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
116 | {6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}.Debug|Any CPU.Build.0 = Debug|Any CPU
117 | {6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}.Release|Any CPU.ActiveCfg = Release|Any CPU
118 | {6A313B1D-BC06-4DE1-B70C-8CAA2E3CA479}.Release|Any CPU.Build.0 = Release|Any CPU
119 | {7C03A5E3-2CB6-42AD-A80D-229EF09E84CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
120 | {7C03A5E3-2CB6-42AD-A80D-229EF09E84CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
121 | {7C03A5E3-2CB6-42AD-A80D-229EF09E84CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
122 | {7C03A5E3-2CB6-42AD-A80D-229EF09E84CB}.Release|Any CPU.Build.0 = Release|Any CPU
123 | {C428373D-B067-47F2-8B71-B7E8D01F6715}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
124 | {C428373D-B067-47F2-8B71-B7E8D01F6715}.Debug|Any CPU.Build.0 = Debug|Any CPU
125 | {C428373D-B067-47F2-8B71-B7E8D01F6715}.Release|Any CPU.ActiveCfg = Release|Any CPU
126 | {C428373D-B067-47F2-8B71-B7E8D01F6715}.Release|Any CPU.Build.0 = Release|Any CPU
127 | {F71FD164-2ECD-4E19-842B-BAED269719A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
128 | {F71FD164-2ECD-4E19-842B-BAED269719A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
129 | {F71FD164-2ECD-4E19-842B-BAED269719A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
130 | {F71FD164-2ECD-4E19-842B-BAED269719A4}.Release|Any CPU.Build.0 = Release|Any CPU
131 | EndGlobalSection
132 | GlobalSection(SolutionProperties) = preSolution
133 | HideSolutionNode = FALSE
134 | EndGlobalSection
135 | GlobalSection(ExtensibilityGlobals) = postSolution
136 | SolutionGuid = {18EA5955-524D-4937-9C48-68A656B974DC}
137 | EndGlobalSection
138 | EndGlobal
139 |
--------------------------------------------------------------------------------