Skip to content
Snippets Groups Projects
Commit f6c58782 authored by Horváth Zoltán's avatar Horváth Zoltán
Browse files

Passing bag as reference (it does not matter, but whatever)

parent 0718815b
Branches
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ internal class Game ...@@ -10,6 +10,7 @@ internal class Game
private readonly int _blue; private readonly int _blue;
public int Id { get; } public int Id { get; }
public int PowerOfCubes => _red * _green * _blue;
internal Game(string line) internal Game(string line)
{ {
...@@ -28,8 +29,7 @@ internal class Game ...@@ -28,8 +29,7 @@ internal class Game
_blue = res["blue"].Single().Amount; _blue = res["blue"].Single().Amount;
} }
public bool PossibleWithBag(Bag bag) => bag.Red >= _red && bag.Green >= _green && bag.Blue >= _blue; public bool PossibleWithBag(in Bag bag) => bag.Red >= _red && bag.Green >= _green && bag.Blue >= _blue;
public int GetPowerOfDies() => _red * _green * _blue;
} }
internal static class Program internal static class Program
...@@ -45,7 +45,7 @@ internal static class Program ...@@ -45,7 +45,7 @@ internal static class Program
.Sum(game => game.Id); .Sum(game => game.Id);
Console.WriteLine($"Sum of IDs is {sum}"); Console.WriteLine($"Sum of IDs is {sum}");
long power = games.Sum(game => game.GetPowerOfDies()); long power = games.Sum(game => game.PowerOfCubes);
Console.WriteLine($"Power of dies is {power}"); Console.WriteLine($"Power of cubes is {power}");
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment