This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day008 | |
| INPUT = File.read("INPUT.txt") | |
| EMPTY = "." | |
| grid = INPUT.to_grid | |
| h = grid.each_with_object(Hash.new { |h, k| h[k] = [] }) { |v, c, memo| memo[c].push(v) if c != EMPTY } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day007 | |
| INPUT = File.read('INPUT.txt') | |
| DATA = INPUT.split("\n").map do |line| | |
| parts = line.split(":") | |
| [ | |
| parts[0].to_i, | |
| parts[1].split(" ").map(&:to_i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day006 | |
| INPUT = File.read('INPUT.txt') | |
| grid = INPUT.to_grid | |
| NORTH = V[0, -1] | |
| SOUTH = V[0, 1] | |
| WEST = V[-1, 0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day005 | |
| INPUT = File.read('INPUT.txt') | |
| rules_raw, updates_raw = INPUT.split("\n\n") | |
| rules = rules_raw.split("\n").map { _1.split("|").map(&:to_i) } | |
| updates = updates_raw.split("\n").map { _1.split(",").map(&:to_i) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day004 | |
| INPUT = File.read('INPUT.txt') | |
| ########## | |
| # Part 1 # | |
| ########## | |
| grid = INPUT.to_grid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day003 | |
| INPUT = File.read('INPUT.txt') | |
| ########## | |
| # Part 1 # | |
| ########## | |
| MUL_REGEX = /mul\(\d+,\d+\)/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day019 | |
| INPUT = File.read('INPUT.txt') | |
| parts = INPUT.split("\n\n") | |
| guides = parts.first.to_lines.map do |guide_line| | |
| guide_pieces = guide_line.split("{") | |
| name = guide_pieces.first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day007 | |
| INPUT = File.read('INPUT.txt') | |
| DATA = INPUT.to_lines.map do |line| | |
| cards, bid = line.split_strip(" ") | |
| { | |
| cards: cards, | |
| bid: bid.to_i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day008 | |
| INPUT = File.read('INPUT.txt') | |
| lines = INPUT.to_lines | |
| instructions = lines.shift.chars | |
| lines.shift | |
| graph = lines.map do |line| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require_relative "main" | |
| module Day009 | |
| INPUT = File.read('INPUT.txt') | |
| lines = INPUT.to_lines | |
| sets = lines.map do |line| | |
| line.split(" ").map(&:to_i) | |
| end |