Giter VIP home page Giter VIP logo

advent-of-code-2018's Introduction

advent-of-code-2018

https://adventofcode.com

This is my attempt at some of the code advent problems. I will try and do them all, but inevitably, I will get bored/stuck at some point and give up.

I'm also going to try and do this in Python to learn something, as I think with R it will either be too easy or too frustrating.

I also want to try and write unit tests for everything, just to try and encourage myself to follow best practices.

What did I learn?

Day 1

  • Using itertools to cycle through the lists is far quicker than any loop
  • Using a dictionary (i.e. curly brackets {}).

Day 2

  • Using enumerate to get an itemised list.
  • Loading in a text file into a list
  • Using Counter from collections to count the number of letters in a string.

Day 3

  • Regular Expressions (though I didn't really learn this - rather just copied all of this from Reddit)
  • Using defaultdict to have a dictionary with a key and then multiple values.

Day 4

  • This is a really hard advent calendar! I think I prefer chocolate.
  • Continued to use defaultdict from the previous day.
  • Using the .split() function instead of regular expressions when all lines have a similar structure.
  • argmax() to return the index/location of the maximum rather than a value.

### Day 5

  • The solution on Reddit was so simple and clean for this, I just copied it and explained what was going on.
  • Again we use list comprehension, but also the .pop() and .append() things are used. I'd particularly never seen .pop() before, but it could be useful.
  • ascii_lowercase is imported from the string library as a reference string used in the second part.

advent-of-code-2018's People

Contributors

mjtriggs avatar

Watchers

James Cloos avatar  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.