m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/05/b.rb
blob: 378f7c60c46d29df6f4afaef6ef3a397d3b41307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
missing = 0
File.readlines('input.txt').map do |line|
  line.tr('FBLR', '0101')
end.map do |line|
  row = line.slice(0, 7).to_i 2
  seat = line.slice(7, 3).to_i 2
  row * 8 + seat
end.sort.reduce do |last_seen, current|
  if current - 1 != last_seen
    missing = current - 1
  end
  current
end

puts missing