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 = 'mjqjpqmgbljsphdztnvjfqwrcgsmlb' | |
# Part 1 | |
input.match(/(.)(?!\1)(.)(?!\1|\2)(.)(?!\1|\2|\3)./).end 0 # => 7 | |
# Part 2 | |
input.match( | |
%r{ | |
(.)(?!.{,12}\1) | |
(.)(?!.{,11}\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
INPUT = <<~CODE | |
[({(<(())[]>[[{[]{<()<>> | |
[(()[<>])]({[<{<<[]>>( | |
{([(<{}[<>[]}>{[]{[(<()> | |
(((({<>}<{<{<>}{[]{[]{} | |
[[<[([]))<([[{}[[()]]] | |
[{[{({}]{}}([{[{{{}}([] | |
{<[[]]>}<{[{[{[]{()[[[] | |
[<(<(<(<{}))><([]([]() | |
<{([([[(<>()){}]>(<<{{ |
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
# Single regex solution for Advent of Code 2020, day 4, part 2 | |
# https://adventofcode.com/2020/day/4 | |
PASSPORTS = <<~TEXT | |
eyr:1972 cid:100 | |
hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926 | |
iyr:2019 | |
hcl:#602927 eyr:1967 hgt:170cm | |
ecl:grn pid:012533040 byr:1946 |
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
p binding.local_variables # => [:foo] | |
p binding.local_variable_get(:foo) # => nil | |
puts "I'm just a buffer" | |
foo = foo |
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
module ActiveRecord | |
module ConnectionAdapters | |
class Column | |
private | |
def simplified_type(field_type) | |
case field_type | |
when /\bint(?:eger)?\b/i | |
:integer | |
when /\b(?:float|double)\b/i |
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
describe "Asm" do | |
it "runs an empty program" do | |
Asm.asm do | |
end.should eq [0, 0, 0, 0] | |
end | |
it "divides positive numbers" do | |
Asm.asm do | |
mov ax, 37 | |
mov bx, 6 |