Code for the Advent of Code event
aoc advent-of-code
at rust 16 lines 307 B view raw
1#!/usr/bin/env ruby 2# frozen_string_literal: true 3 4require_relative 'engine' 5 6input = $stdin.readlines.map { |l| l.split.map(&:to_i) } 7 8triangles = [] 9 10input.each_slice(3) do |rows| 11 (0..2).each do |col| 12 triangles << [rows[0][col], rows[1][col], rows[2][col]] 13 end 14end 15 16puts count_triangles triangles