GithubHelp home page GithubHelp logo

advent-2018's Introduction

advent-2018

Advent of Code 2018 solutions in Kotlin

This is me trying to get to know Kotlin, I did previous years in Scala. I noticed that at the end, when revisiting my earlier solutions, I could clean them up quite a bit so at least I've learned something.

Initial setup copied from Todd Ginsberg who has a great repo with accompanying blog that you should definitely look at if you have not already.

Files you may find interesting:

Kotlin sequence block is very handy, I retrofitted one into Day 1 as well.

I managed to reduce the move method to a single breadth-first search with a little bit of extra administration.

Used the sort-of-normalized form of the input to solve that one with minimal means. No need to create a map of the dungeon.

I tried so many things here, my initial idea was to solve the problem at a coarser resolution and then repeatedly zoom in to find the exact point. Worked alright for my own input but for other inputs this fails. Then I tried some heuristic optimisation techniques which failed as well. Finally I saw someone who kept splitting a box into eight parts, tracking the one that overlaps with the most spheres. So simple that I should've thought of it, and efficient enough to work for all inputs that I saw.

I am used to the extremely consistent and well-designed Scala standard library and hopping over to Kotlin took a little getting used to. But the ability to create a little advent-of-code library made up for some of the hardship. The first time you notice you can re-use methods you put on certain classes is good fun.

advent-2018's People

Contributors

fdlk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.