# Idiomatic Kotlin: Solving Advent of Code Puzzles, Binary Boarding

DevFeed: [Idiomatic Kotlin: Solving Advent of Code Puzzles, Binary Boarding](<https://devfeed.tech/articles/idiomatic-kotlin-solving-advent-of-code-puzzles-binary-boarding-22984.md>)

Original publisher: [Read original article](<https://dev.to/kotlin/idiomatic-kotlin-solving-advent-of-code-puzzles-binary-boarding-513e>)

Author: Svetlana Isakova

Published: 2021-09-10T08:50:58Z

Content type: tutorial

Language: en

Sources: [Kotlin](<https://devfeed.tech/sources/kotlin-2.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Code Challenge](<https://devfeed.tech/topics/code-challenge.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [100daysofcode](<https://devfeed.tech/tags/100daysofcode.md>), [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [adventofcode](<https://devfeed.tech/tags/adventofcode.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [code-challenge](<https://devfeed.tech/tags/code-challenge.md>), [codenewbie](<https://devfeed.tech/tags/codenewbie.md>), [coding](<https://devfeed.tech/tags/coding.md>), [community](<https://devfeed.tech/tags/community.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

A Kotlin tutorial solves Advent of Code 2020 Day 5, Binary Boarding. It explains how boarding-pass characters encode rows and columns as binary values, then uses seat IDs to identify the highest seat ID and the missing seat.

## Source excerpt

Let's continue our journey of understanding what "idiomatic Kotlin" means and solve one more puzzle from the Advent of Code challenge. The puzzles are independent of each other, so you don't need to check any of the previous ones we've already covered. Simply read through the following solution or watch the video. We hope you learn something new! Day 5. Binary Boarding We're boarding the plane! We need to analyze the list of boarding passes and find the seat with the highest seat ID. Then we need to find the one seat missing from the list, which is ours. You can find the full task description at https://adventofcode.com/2020/day/5.* A seat is specified as, for example, FBFBBFFRLR, where F means "front", B means "back", L means "left", and R means "right". The first 7 characters are either F or B and they specify exactly one of the 128 rows on the plane (numbered 0 through 127). The last three characters are either L or R; these specify exactly one of the 8 columns of seats on the plane (numbered 0 through 7). A more detailed encoding description is given on the puzzle page. Every seat has a unique seat ID, calculated by multiplying the row by 8 and then adding the column. The puzzle input is the list of boarding passes. The first task is to find the boarding pass in this list with the highest seat ID. The second task is to find the missing boarding pass in the list. The flight is completely full, there's only one missing boarding pass, and that's our seat. However, some of the seats at the very front and back of the plane don't exist on this aircraft, so they are missing from the list as well. As usual, we suggest that you try to solve the task on your own before reading the solution. Here's how you can set up Kotlin for this purpose. Solution Let's first discuss the encoding of the boarding passes. Note how it is a nicely "hidden" binary representation of natural numbers! Let's take a closer look. Boarding pass: binary representation First, let's look at the rows.