minor optimization
This commit is contained in:
@@ -28,10 +28,10 @@ internal class Scratchcards : Problem<double, int>
|
|||||||
{
|
{
|
||||||
var card = _cards[i];
|
var card = _cards[i];
|
||||||
var wins = card.have.Intersect(card.win).Count();
|
var wins = card.have.Intersect(card.win).Count();
|
||||||
|
var cCount = GetCardCount(card.card);
|
||||||
for (int j = 1; j <= wins; j++)
|
for (int j = 1; j <= wins; j++)
|
||||||
AddCards(card.card + j, GetCardCount(card.card));
|
AddCards(card.card + j, cCount);
|
||||||
Part2 += wins * GetCardCount(card.card);
|
Part2 += wins * cCount;
|
||||||
//_cardCount[card.card] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,6 @@ internal class Scratchcards : Problem<double, int>
|
|||||||
{
|
{
|
||||||
if(_cardCount.TryGetValue(card, out var count))
|
if(_cardCount.TryGetValue(card, out var count))
|
||||||
return count;
|
return count;
|
||||||
//_cardCount.Add(card, 1);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user