about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2021-12-23 13:50:48 -0500
committerBen Harris <ben@tilde.team>2021-12-23 13:50:48 -0500
commit5c32a53ad31207d42667ceba5e1ca96add649ca4 (patch)
tree5d551c2c51c87684d24e85b1e02e7e6018528aa5
parent9edb557cd9a1afbe47955b725f5161026fb0fb34 (diff)
use GetValueOrDefault
-rw-r--r--aoc2021/Day21.cs9
1 files changed, 2 insertions, 7 deletions
diff --git a/aoc2021/Day21.cs b/aoc2021/Day21.cs
index cae9f07..7c68067 100644
--- a/aoc2021/Day21.cs
+++ b/aoc2021/Day21.cs
@@ -109,13 +109,8 @@ public sealed class Day21 : Day
         for (var x = 1; x <= 3; x++)
         for (var y = 1; y <= 3; y++)
         for (var z = 1; z <= 3; z++)
-        {
-            var total = x + y + z;
-            if (!_possibleRollOutComes.ContainsKey(total))
-                _possibleRollOutComes[total] = 1;
-            else
-                _possibleRollOutComes[total]++;
-        }
+            _possibleRollOutComes[x + y + z] =
+                _possibleRollOutComes.GetValueOrDefault(x + y + z, 0ul) + 1ul;
 
         RollDiracDie(0, 0, _player1, _player2, 1, 1);