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/2019/ruby/day_04.rb

7 lines
257 B

# typed: strict
puts (236491..713787).map(&:to_s).count {|password|
matching_digits = password.scan(/(.)\1/)
!matching_digits.empty? && matching_digits.flatten.any? {|d| !password.include?(d * 3) } && password.chars.each_cons(2).all? {|a,b| a <= b }
}