Giter VIP home page Giter VIP logo

adventofcode_2018's Introduction

The 25 Days of Christmas

Ho, ho, ho!

This is a simple implementation for the challenges at https://adventofcode.com/2018. Enjoy!

Details

Each solution was created via cargo init day_NN --vcs none, and (usually) have an independent src/part1.rs and src/part2.rs, so you can easily see what was changed to finish the second half.

I focused on a balance between code readability and writing speed: I want to get these done quickly, but I also want to come back at some point and figure out what I did.

There is a README for each day, which is scraped directly from the website itself to describe the problem being solved. All rights, credit, blame, etc. goes to that website and its author(s).

Comments

Day 1

Did this with a throw-away bit of javascript. Shame on me! The future is rust!

Day 2

In hindsight, Rust already has a perfectly good bool_to_int in the form of b.into(). (or rev_bool_to_int as (!b).into()) ๐Ÿคท

Day 3

Part 2 should have been done with k-d trees or something. It's just that build/running with --release is so fast, you can get away with brute forcing the problem.

OTOH, using a lalrpop grammar for the input is probably overkill, since it's O(n) right at the top of the problem. Makes it easy to read, tho.

Day 4

I'm generally trying to stick to the std crate, but itertools was too good to pass up for this one.

Day 5

Rust has fully bought into UTF8, so there's no easy byte -> byte conversion for ASCII flipping upper/lowercase. (The uppercase of a character might be a multi-char symbol, each char of which might be multibyte). Guess I'll write my own...

Day 6

Still should use k-d or something for part 2 instead of brute force.

Day 7

This is a bit over-engineered; but it is, I think, the optimal algorithm.

Day 8

Loved this one, probably because I love recursive problems (see day 8).

Day 9

Part 2 runs so slow: I should have implemented a circular buffer or something. cargo run --release to get past it.

Day 10

I assumed that the message would show at or near the local minimum, and was right. Not sure what I would have done if that wasn't true. My y-axis was flipped, tho, so the message appears upside-down.

Day 11

Should have used Summed-area tables for part 2. As it is, I have just a little bit of result re-use but it's mostly brute force. --release to the rescue again, I guess.

Day 12

After the debacles on day 9 and 11, implemented my own windowed 2-way infinite buffer, which is probably overkill.

Day 13

This is way too much code. Provided an alternate solution (which doesn't bother parsing the track) in alt_part2.rs, but it's really still too long.

Day 14

I probably should have been using slice comparison for earlier problems. The last_dig check is purely for opimization, but significantly speeds up the calculation. (Down to ~3.5 seconds on my box in debug)

Day 15

Compulsively found the pathfinding algorithm with optimal worst-case: the modified A* here; but lost readability, writing time, best-case and avarage-case time, sanity in trade. Even missed some edge cases (which fortunately didn't come up in my problem input).

I now have a cleaned-up version of part 1 with vastly simplified (and thus both more readable and performant) pathfinding, but it's probably still missing that edge case.

adventofcode_2018's People

Contributors

chaaz 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.