Permalink
Browse files

Four4Sample - support digits other than 4 in app

  • Loading branch information...
bobbymcr committed Mar 17, 2018
1 parent c23ec7d commit 96e84f690e4d084e70a0ce92cc280fdea2daabe4
Showing with 27 additions and 6 deletions.
  1. +27 −6 projects/Four4Sample/Four4/Program.cs
@@ -13,7 +13,9 @@ private static void Main(string[] args)
{
Stopwatch stopwatch = Stopwatch.StartNew();
ExpressionSearch search = InitSearch();
char d = GetDigit(args);
ExpressionSearch search = InitSearch(d);
Results results = new Results();
search.Run(e => OnFound(results, e));
@@ -27,8 +29,27 @@ private static void Main(string[] args)
}
}
private static ExpressionSearch InitSearch()
private static char GetDigit(string[] args)
{
char d = '4';
if ((args.Length != 0) && (args[0].Length > 0))
{
char c = args[0][0];
switch (c)
{
case '3':
case '4':
d = c;
break;
}
}
return d;
}
private static ExpressionSearch InitSearch(char c)
{
string d = c.ToString();
ExpressionSearch search = new ExpressionSearch();
search.AddOperator("+");
search.AddOperator("-");
@@ -37,10 +58,10 @@ private static ExpressionSearch InitSearch()
search.AddOperator("^");
search.AddOperator("!");
search.AddOperator("R");
search.AddOperand("44");
search.AddOperand("4");
search.AddOperand(".4");
search.AddOperand(".4_");
search.AddOperand(d + d);
search.AddOperand(d);
search.AddOperand("." + d);
search.AddOperand("." + d + "_");
return search;
}

0 comments on commit 96e84f6

Please sign in to comment.