Skip to content

Commit

Permalink
Add Grid<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpunk2099 committed Jun 6, 2019
1 parent bfe972d commit 32d8b25
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/ProjectEuler/ProjectEuler.Problems/Helpers/Grid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace ProjectEuler.Problems.Helpers
{
public class Grid<T>
{
public T[,] Values { get; }

public T this[int col, int row]
{
get => Values[col, row];
set => Values[col, row] = value;
}

public int ColCount { get; }
public int RowCount { get; }

public Grid(int colCount, int rowCount)
{
if (colCount < 1 || rowCount < 1)
throw new ArgumentOutOfRangeException();

ColCount = colCount;
RowCount = rowCount;
Values = new T[ColCount, RowCount];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Problem007 : IProblem
public int Id => 7;
public string Title => "10001st prime";

private const int UpperBound = 10001;
public const int UpperBound = 10001;

public string Description =>
"By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, " +
Expand Down

0 comments on commit 32d8b25

Please sign in to comment.