Update code to use advent lib.

This commit is contained in:
Danila Fedorin 2020-12-05 16:06:51 -08:00
parent e9d0701b4c
commit 479b1d745e
7 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,5 @@
INPUT = File.read("day1.txt").lines.map(&.chomp.to_i32) require "advent"
INPUT = input(2020, 1).lines.map(&.chomp.to_i32)
def part1 def part1
input = INPUT.clone.sort! input = INPUT.clone.sort!

View File

@ -1,4 +1,5 @@
INPUT = File.read("day2.txt").lines.map(&.chomp) require "advent"
INPUT = input(2020, 2).lines.map(&.chomp)
def parse(line) def parse(line)
data = line.match(/([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)/) data = line.match(/([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)/)

View File

@ -1,4 +1,5 @@
INPUT = File.read("day3.txt").lines.map(&.chomp) require "advent"
INPUT = input(2020, 3).lines.map(&.chomp)
def run(input, slopes) def run(input, slopes)
prod = 1_i64 prod = 1_i64

View File

@ -1,5 +1,6 @@
require "./passports.cr" require "./passports.cr"
INPUT = File.read("day4.txt") require "advent"
INPUT = input(2020, 4)
def part1 def part1
input = INPUT.clone input = INPUT.clone

View File

@ -1,4 +1,5 @@
INPUT = File.read("day5.txt").lines.map(&.chomp) require "advent"
INPUT = input(2020, 5).lines.map(&.chomp)
def partition(choices, list) def partition(choices, list)
b = 0 b = 0

2
day5g.cr Normal file
View File

@ -0,0 +1,2 @@
i=File.read_lines("day5.txt").map &.tr("FBLR", "0101").to_i32(2);
puts({i.max,(i.min..i.max).select{|n|!i.includes? n}})

View File

@ -1,4 +1,5 @@
INPUT = File.read("dayN.txt")#.lines.map(&.chomp) require "advent"
INPUT = input(2020, n)#.lines.map(&.chomp)
def part1 def part1
input = INPUT.clone input = INPUT.clone