This file contains 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
@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| | |
{ |
This file contains 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
@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", '') |
This file contains 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
@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 |
This file contains 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
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}" |
This file contains 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
@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 |
This file contains 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
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 |
This file contains 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
passports = File.open('input.txt').read.split("\n\n") | |
class Passport | |
REQUIRED_FIELDS = %w[ | |
byr | |
iyr | |
eyr | |
hgt | |
hcl | |
ecl |
This file contains 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
.git | |
.gitignore | |
README.md | |
# | |
# OS X | |
# | |
.DS_Store | |
.AppleDouble | |
.LSOverride |
This file contains 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
$ 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 :( |
This file contains 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
$ 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 ~ | |
$ |
NewerOlder