Kotlin Day 0

Advent of Code 2015

Fang Jin
2 min readSep 3, 2020
From Dusk till Dawn

From Advent of Code 2015.

((((()))))))))))
15x24x8
v>v<vvv<<vv^v<v>vv>v<<<^^^
vfarmltinsriqxpu
toggle 857,493 through 989,970
dd RSHIFT 3 -> df
"kbngyfvvsdismznhar\\p\"\"gpryt\"jaeh"

Each day we start with a file,

Each line corresponds to an item,

Let it be a box, a secret, or a map …

Model

Given a string, build a model to facilitate the work.

Most of the work requires to build list of models from multiple lines.

If lines are stored in a file, we can load them.

Kotlin — Parse a file

Part 1

What’s your general practice looking for an answer?

Ready, Go — Finding the answer

Normally it takes a few steps.

  • If data isn’t ready, preparation work is required to get the data and put into the right format.
  • Data then passes through each step of the problem, and results in the intermediate data as the input for the next step.
  • Once the problem is solved, it reaches the aggregation where we make a decision in the format of the result for the output.

Each of the above could have its own complexity, which might splits into more steps.

Part 2

What’s your better chance of finding the right answer in a consistent manner?

Test is an early plan of how you measure the success of the solution, and if better crafted, should reveal how you decouple and assemble all units back to solve the puzzle.

Your driver of writing test early on is mostly driven by your eagerness of having a solid solution in the end. Your reputation is on the line, your money is in the pot, but how can you increase the chance of the success before working towards it?

Highlights

  • How to approach a problem?
  • How to increase chance of solving it?

Now, ready for the next day? Day 1 — Not Quite Lisp

For Complete source code, please visit AoC 2015 Kotlin.

--

--

Fang Jin
Fang Jin

Written by Fang Jin

Front-end Engineer, book author of “Designing React Hooks the Right Way” and "Think in Recursion"

No responses yet