Update code to use advent lib.
This commit is contained in:
parent
e9d0701b4c
commit
479b1d745e
3
day1.cr
3
day1.cr
|
@ -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!
|
||||
|
|
3
day2.cr
3
day2.cr
|
@ -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]+)/)
|
||||
|
|
3
day3.cr
3
day3.cr
|
@ -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
|
||||
|
|
3
day4.cr
3
day4.cr
|
@ -1,5 +1,6 @@
|
|||
require "./passports.cr"
|
||||
INPUT = File.read("day4.txt")
|
||||
require "advent"
|
||||
INPUT = input(2020, 4)
|
||||
|
||||
def part1
|
||||
input = INPUT.clone
|
||||
|
|
3
day5.cr
3
day5.cr
|
@ -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
|
||||
|
|
2
day5g.cr
Normal file
2
day5g.cr
Normal 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}})
|
|
@ -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…
Reference in New Issue
Block a user