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 Day018 | |
| INPUT = File.read("INPUT.txt") | |
| SIDE = 71 | |
| LIMIT = 1024 | |
| CORRUPT = "#" | |
| SAFE = "." |
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 Day017 | |
| INPUT = File.read("INPUT.txt") | |
| ########## | |
| # Part 1 # | |
| ########## | |
| parts = INPUT.split("\n\n") |
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 Day016 | |
| INPUT = File.read("INPUT.txt") | |
| grid = INPUT.to_grid | |
| CHAR_START = "S" | |
| CHAR_END = "E" | |
| EAST = 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 Day015 | |
| INPUT = File.read("INPUT.txt") | |
| ROBOT = "@" | |
| BOX = "O" | |
| WALL = "#" | |
| 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 Day014 | |
| INPUT = File.read("INPUT.txt") | |
| WIDTH = 101 | |
| HEIGHT = 103 | |
| rs = INPUT.split("\n").map do |line| | |
| line.split(" ").map do |chunk| | |
| V[*chunk.split("=").last.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 Day013 | |
| INPUT = File.read("INPUT.txt") | |
| answer1 = 0 | |
| answer2 = 0 | |
| INPUT.split("\n\n").each do |group| | |
| ax, ay, bx, by, px1, py1 = group.split("\n").map { |line| line.split(",").map { |s| s[/\d+/].to_i } }.flatten |
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 Day012 | |
| INPUT = File.read("INPUT.txt") | |
| grid = INPUT.to_grid | |
| origins = grid.each_with_object(Hash.new { |h, k| h[k] = [] }) { |v, value, a| a[value].push(v) } | |
| answer1 = 0 | |
| answer2 = 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 Day011 | |
| INPUT = File.read("INPUT.txt") | |
| s = INPUT.split.map { [_1.to_i, 1] }.to_h | |
| convert = ->(n) do | |
| return [1] if n == 0 | |
| t = n.to_s |
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") | |
| s = INPUT.strip | |
| expand = ->(s) { s.chars.each_with_object([]).with_index { |(c, a), i| c.to_i.times { a.push(i.even? ? i / 2 : nil) } } } | |
| checksum = ->(a) { a.each_with_index.sum { _2 * _1.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 Day010 | |
| INPUT = File.read("INPUT.txt") | |
| grid = INPUT.to_grid(cast_int: true) | |
| v0s = grid.each_with_object([]) { |v, h, a| a.push(v) if h == 0 } | |
| ########## |
NewerOlder