Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
336 B · 14 lines
Ruby
at rust
123456789101112131415#!/usr/bin/env ruby# frozen_string_literal: true
fish = ARGF.read.split(',').map(&:to_i).tally.tap { _1.default = 0 }
256.times do |n| temp = fish.dup fish = temp.reject { _1 == 0 }.to_h { [_1 - 1, _2] }.tap { _1.default = 0 } fish[6] += temp[0] fish[8] += temp[0] puts fish.values.sum if n == 79end
puts fish.values.sum