Mercurial > repos > other > adventofcode2023
changeset 8:51e5f26dc81e
Add a template file for reuse
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 07 Dec 2023 19:41:46 +0000 |
parents | 6e0615e54e71 |
children | 9ec95ff0d33d |
files | day6.rb template.rb |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/day6.rb Thu Dec 07 08:23:04 2023 +0000 +++ b/day6.rb Thu Dec 07 19:41:46 2023 +0000 @@ -8,7 +8,7 @@ file = ARGV[0] -times, distances = File.open(file, "r").each_line(chomp: true).map {|v| v.split(":")[1].split(" ").map(&:to_i)} +times, distances = File.open(file, "r").each_line(chomp: true).map {|v| puts v; puts v.split(":"); v.split(":")[1].split(" ").map(&:to_i)} events = times.zip(distances) product = events.map do |event|
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/template.rb Thu Dec 07 19:41:46 2023 +0000 @@ -0,0 +1,12 @@ +#! /usr/bin/env ruby + +if ARGV.length != 1 + abort("Incorrect arguments - needs input file") +elsif not File.exist? (ARGV[0]) + abort("File #{ARGV[0]} did not exist") +end + +file = ARGV[0] + +File.open(file, "r").each_line(chomp: true).… +# Rest of algorithm here \ No newline at end of file