Skip to content

Instantly share code, notes, and snippets.

Avatar
🚂

Mike Rogers MikeRogers0

🚂
View GitHub Profile
@MikeRogers0
MikeRogers0 / aoc_2020_day_16_part_two.rb
Created Dec 16, 2020
Advent Of Code - Day 16: Part 2
View aoc_2020_day_16_part_two.rb
@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 Dec 16, 2020
Advent Of Code - Day 16: Part 1
View aoc_2020_day_16_part_one.rb
@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 Dec 15, 2020
Advent of code 2020 Day 15
View aoc_2020_day_15.rb
@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 Dec 13, 2020
AOC 2020 - Day 12, part 2
View aoc_2020_day_12_part_two.rb
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}"
View aoc_2020_day_11_part_two.rb
@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 Dec 10, 2020
Advent Of Code 202 - day 9
View aoc_2020_day_9.rb
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 Dec 4, 2020
Advent Of Code - Day 4 (Part two) - Ruby
View aoc_day_4_part_two.rb
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 Apr 9, 2020
Docker Setup for AWS Beanstalk
View .dockerignore
.git
.gitignore
README.md
#
# OS X
#
.DS_Store
.AppleDouble
.LSOverride
View gist:91515fe966b1d89a5b822fe74ad246bb
$ 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 :(
View gist:91a0bf83acc90d8f8b5a87ad6e076f48
$ 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 ~
$