Skip to content

Instantly share code, notes, and snippets.

View MikeRogers0's full-sized avatar
🚂

Mike Rogers MikeRogers0

🚂
View GitHub Profile
@MikeRogers0
MikeRogers0 / aoc_2020_day_16_part_two.rb
Created December 16, 2020 14:15
Advent Of Code - Day 16: Part 2
@section = File.open('input.real.txt').read.split("\n\n").compact
# Get all the rules as ranges (e.g. 0..3), with their names.
@rules = @section[0]
.split("\n")
.collect { |line|
line.scan(/(.+): ([0-9\-]+)-([0-9]+) or ([0-9\-]+)-([0-9]+)/ism).flatten
}
.collect { |name, start_range_1, end_range_1, start_range_2, end_range_2|
{
@MikeRogers0
MikeRogers0 / aoc_2020_day_16_part_one.rb
Created December 16, 2020 14:14
Advent Of Code - Day 16: Part 1
@section = File.open('input.real.txt').read.split("\n\n").compact
# Get all the rules as ranges (e.g. 0..3)
@rules = @section[0]
.scan(/([0-9\-]+)-([0-9]+)/im)
.collect { |start_range, end_range| (start_range.to_i..end_range.to_i) }
# Get all the numbers on the nearby tickets
@nearby_ticket_numbers = @section[2]
.gsub("nearby tickets:\n", '')
@MikeRogers0
MikeRogers0 / aoc_2020_day_15.rb
Created December 15, 2020 11:02
Advent of code 2020 Day 15
@input = [0,12,6,13,20,1,17]
@numbers = {}
@input.each_with_index do |input, index|
@numbers[input] = { count: 1, last_spoken_on: index + 1, last_spoken_before_on: nil }
end
@last_number_spoken = @input.last
@turn_count = @input.length + 1
@MikeRogers0
MikeRogers0 / aoc_2020_day_12_part_two.rb
Last active December 13, 2020 12:05
AOC 2020 - Day 12, part 2
class Ship
def initialize
@x = 0
@y = 0
@waypoint_x = 10
@waypoint_y = 1
end
def rotate!(direction, degrees_to_turn)
puts "Waypoint was: #{current_waypoint}"
@rows = {}
File.open('input.real.txt').read.split("\n").compact.each_with_index do |row, index|
@rows[index] = {}
row.each_char.with_index do |element, element_index|
@rows[index][element_index] = element
end
end
@last_row = @rows.keys.last
@last_column = @rows[0].keys.last
@MikeRogers0
MikeRogers0 / aoc_2020_day_9.rb
Created December 10, 2020 11:16
Advent Of Code 202 - day 9
def number_is_not_sum_of_previous_preamble?(index)
numbers = @numbers[(index - 25)...(index)]
aim_number = @numbers[index]
numbers.each do |number_1|
numbers.each do |number_2|
combined_number = number_1 + number_2
return true if combined_number == aim_number
end
end
@MikeRogers0
MikeRogers0 / aoc_day_4_part_two.rb
Last active December 4, 2020 10:39
Advent Of Code - Day 4 (Part two) - Ruby
passports = File.open('input.txt').read.split("\n\n")
class Passport
REQUIRED_FIELDS = %w[
byr
iyr
eyr
hgt
hcl
ecl
@MikeRogers0
MikeRogers0 / .dockerignore
Last active April 9, 2020 12:52
Docker Setup for AWS Beanstalk
.git
.gitignore
README.md
#
# OS X
#
.DS_Store
.AppleDouble
.LSOverride
$ brew uninstall dart; brew reinstall sass
Uninstalling /usr/local/Cellar/dart/2.0.0-dev.59.0... (1,206 files, 348.9MB)
dart 1.24.3 1 is still installed.
Remove all versions with `brew uninstall --force dart`.
==> Reinstalling sass/sass/sass
Error: /usr/local/opt/dart not present or broken
Please reinstall dart-lang/dart/dart. Sorry :(
$ brew reinstall sass/sass/sass
==> Reinstalling sass/sass/sass
==> Downloading https://github.com/sass/dart-sass/archive/1.4.0.tar.gz
Already downloaded: /Users/Mike/Library/Caches/Homebrew/sass-1.4.0.tar.gz
==> /usr/local/opt/dart/bin/pub get
==> /usr/local/opt/dart/bin/dart --snapshot=sass.dart.app.snapshot --snapshot-kind=app-jit bin/sass.dart tool/app-snapshot-input.scss
🍺 /usr/local/Cellar/sass/1.4.0: 9 files, 29.9MB, built in 23 seconds
Mike at Michaels-MacBook-Pro in ~
$