Code for the Advent of Code event
aoc
advent-of-code
1#!/usr/bin/env ruby
2# frozen_string_literal: true
3
4fish = ARGF.read.split(',').map(&:to_i).tally.tap { _1.default = 0 }
5
6256.times do |n|
7 temp = fish.dup
8 fish = temp.reject { _1 == 0 }.to_h { [_1 - 1, _2] }.tap { _1.default = 0 }
9 fish[6] += temp[0]
10 fish[8] += temp[0]
11 puts fish.values.sum if n == 79
12end
13
14puts fish.values.sum