Helps to actually commit the code
This commit is contained in:
parent
7c29291c0f
commit
00411149e6
1 changed files with 25 additions and 2 deletions
|
@ -141,6 +141,29 @@ net.Receive("AOC:Part2", function()
|
||||||
local ent = net.ReadEntity()
|
local ent = net.ReadEntity()
|
||||||
local input = net.ReadString()
|
local input = net.ReadString()
|
||||||
|
|
||||||
print('Part 2')
|
local power_sum = 0
|
||||||
print(input)
|
for i, line in pairs(split(input, '\n')) do
|
||||||
|
local game = parseGame(line)
|
||||||
|
print('Game '..game.id)
|
||||||
|
|
||||||
|
local min_red_needed = 0
|
||||||
|
local min_grn_needed = 0
|
||||||
|
local min_blu_needed = 0
|
||||||
|
|
||||||
|
for i, play in pairs(game.draws) do
|
||||||
|
print(' play '..i)
|
||||||
|
print(' red: '..play.red)
|
||||||
|
print(' grn: '..play.green)
|
||||||
|
print(' blu: '..play.blue)
|
||||||
|
|
||||||
|
if play.red > min_red_needed then min_red_needed = play.red end
|
||||||
|
if play.green > min_grn_needed then min_grn_needed = play.green end
|
||||||
|
if play.blue > min_blu_needed then min_blu_needed = play.blue end
|
||||||
|
end
|
||||||
|
local power = min_red_needed * min_grn_needed * min_blu_needed
|
||||||
|
print(' power '..power)
|
||||||
|
power_sum = power_sum + power
|
||||||
|
end
|
||||||
|
|
||||||
|
print('Sum of powers: '..power_sum)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue