Git Product home page Git Product logo

advent2019's Introduction

Advent of Code 2019 Notes

Questions corresponding to the script can be found here: Advent of Code 2019

Day 1

Recursion does the trick.

Day 2

  • intList = list(map(int, stringList)) to convert a list of string to list of int.
  • recursion does the trick again.
  • Another thing to note is using copy.deepcopy() to create a copy of a list (reference type)
    • 2019/12/03 UPDATE: duplicating list can also be done by l2 = l1[:]

Day 3

There might be a better data structure for the paths - I chose to record every point that it crossed. The data size is not that big so performance was ok. I did encounter performance issue trying to find the common coordinates of the two paths. At first, I was using:

listOfCross = []
for point in firstCoordinates:
    if point in secondCoordinates:
        listOfCross.append(point)

It was slow. A bit of research and I found this thread on StackOverflow

listOfCross = list(set(firstCoordinates).intersection(secondCoordinates))

Neat.

Jonathan Paulson’s solution is really elegant.

Day 4

This one was pretty straight-forward. Most of time was spent on understand the requirement of part 2.

Could have read in the number as string to get the digits.

advent2019's People

Stargazers

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