aboutsummaryrefslogtreecommitdiff
path: root/day04/part2
diff options
context:
space:
mode:
Diffstat (limited to 'day04/part2')
-rwxr-xr-xday04/part218
1 files changed, 18 insertions, 0 deletions
diff --git a/day04/part2 b/day04/part2
new file mode 100755
index 0000000..b9d5b72
--- /dev/null
+++ b/day04/part2
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+
+def valid(line)
+ arr = line.split
+ (0...arr.length).each do |i|
+ perms = arr[i].chars.permutation
+ (i+1...arr.length).each do |j|
+ return false if perms.include?(arr[j].chars)
+ end
+ end
+ return true
+end
+
+input = $stdin.readlines.map(&:chomp)
+
+puts input.select { |line|
+ valid(line)
+}.length