16 lines
317 B
Crystal
16 lines
317 B
Crystal
|
lines = File.read("day2").split("\n")
|
||
|
lines.pop
|
||
|
|
||
|
def count_changes(s1, s2)
|
||
|
pairs = s1.chars.zip s2.chars
|
||
|
total = 0
|
||
|
pairs.each do |pair|
|
||
|
total += 1 if pair[0] != pair[1]
|
||
|
end
|
||
|
return total
|
||
|
end
|
||
|
|
||
|
lines.product(lines).each do |pair|
|
||
|
puts "#{pair[0]}, #{pair[1]}" if count_changes(pair[0], pair[1]) == 1
|
||
|
end
|