Coder Social home page Coder Social logo

advent-of-code-2022's Introduction

Advent of Code 2022

My attempt at the Advent of Code 2022 challenges, done in JavaScript

What I learned on each day

Day 1 - reading from files in JS, sorting arrays in JS
Day 2 - using char codes(?)
Day 3 - exploiting the use of null as false for conditions
Day 4 - swapping parameters to a function, string formatting in JS
Day 5 - array shifting/unshifting/splicing, shallow copies of arrays, using regex in str.replace()
Day 6 - set objects
Day 7 - array sums (via arr.reduce()), filtering, refreshing my recursion knowledge
Day 8 - array methods: .findIndex() and .every()
Day 9 - sometimes brute force works...
Day 10 - using .forEach() for better clarity & succinctness
Day 11 - a modular arithmetic property: $\forall k.\ ((a \mod km) \mod m = a \mod m)$, plus improving my input parsing
Day 12 - BFS for undirected unweighted graphs, more succinct 2D array initialisation
Day 13 - multiple args in .forEach(element, index, array), realising indexOf() doesn't work as intended for subarrays, JSON.parse() as an alternative to eval() for strings of arrays
Day 14 - creating a "range"-like array in one line, and an alternative solution is memoizing the path of each previous grain of sand and then starting at the last position before it landed (although I didn't implement this)
Day 15 - max = Math.max(max, x); instead of if (x > max) max = x; (and likewise for min), for ... of loops (I should've known about this way earlier), and sometimes functions originally intended to return booleans don't always have only two outcomes

Day 20 - modulo vs. remainder (i.e. function mod(a, b) {return ((a % b) + b) % b;})

Total stars: 36/50

advent-of-code-2022's People

Contributors

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