From 17ec01ad9efc2074215c85b90b79abd2aab803a2 Mon Sep 17 00:00:00 2001 From: Jeff Yates Date: Thu, 3 Dec 2020 09:09:54 -0500 Subject: [PATCH] coded solution --- day03/solution1.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 day03/solution1.rb diff --git a/day03/solution1.rb b/day03/solution1.rb new file mode 100755 index 0000000..4917e3a --- /dev/null +++ b/day03/solution1.rb @@ -0,0 +1,24 @@ +#!/bin/env ruby + +input = Array.new +File.readlines('./input').each.with_index do |line, i| + line.strip! + input[i] = line.split('') +end + +input.each do |x| + x.map! do |y| + y == '#' ? true : false + end +end + +i = 0 +trees = 0 +len = input[0].length +input.each do |row| + trees += 1 if row[i] + i +=3 + i = i - len if i >= len +end + +puts "We hit #{trees} trees" \ No newline at end of file