From 5c32a53ad31207d42667ceba5e1ca96add649ca4 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 23 Dec 2021 13:50:48 -0500 Subject: [PATCH] use GetValueOrDefault --- aoc2021/Day21.cs | 9 ++------- 1 file 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);