aboutsummaryrefslogtreecommitdiff
path: root/day04/part2
blob: b9d5b72e471ed7e84a3018e5d7567ad4fa123357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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