From 6567cc4e483d189051dba2ca7fb64420902e067e Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Thu, 10 Dec 2015 21:43:16 -0800 Subject: [PATCH] Day 11.0 --- day_11.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 day_11.rb diff --git a/day_11.rb b/day_11.rb new file mode 100644 index 0000000..5da77f1 --- /dev/null +++ b/day_11.rb @@ -0,0 +1,17 @@ +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 + +seed = "cqjxjnds" +while true + seed = seed.succ + break if seed.password? +end +puts seed