Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
433 B · 16 lines
Ruby
at rust
1234567891011121314151617#!/usr/bin/env ruby# frozen_string_literal: true
class CPU def initialize; @r = Hash.new(0) end def inc(v) v end def dec(v) -v end def run(text) eval text end def method_missing(s, *a) (@r[s] += a[0].to_i).tap { |v| @h = v if @h.nil? || @h < v } end def respond_to_missing?(s, *) s =~ /^[a-z]$/ endend
cpu = CPU.newcpu.run $<.readputs cpu.instance_variable_get('@r').values.maxputs cpu.instance_variable_get('@h')