Update code to use advent lib.

master
Danila Fedorin 3 years ago
parent e9d0701b4c
commit 479b1d745e

@ -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
input = INPUT.clone.sort!

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

@ -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)
prod = 1_i64

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

@ -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)
b = 0

@ -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}})

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

Loading…
Cancel
Save