You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2015/ruby/day_11.rb

18 lines
347 B

9 years ago
class String
REQUIRED_SUBSTRING = (?a..?z).each_cons(3).map(&:join)
PAIRS = (?a..?z).map {|c| c*2 }
def password?
REQUIRED_SUBSTRING.any? {|s| self.include?(s) } &&
self !~ /[iol]/ &&
PAIRS.count {|p| self.include?(p) } >= 2
end
end
9 years ago
seed = "cqjxxyzz"
9 years ago
while true
seed = seed.succ
break if seed.password?
end
puts seed