Code Monkey home page Code Monkey logo

advent-of-code-15's Introduction

advent-of-code-15

This is my attempt to solve one of the Advent of Code puzzle using TypeScript

Disclaimer

I'm not new to Typescript, but I'm also a junior developer
Learning to debug is part of a developer's career and I'm challenging myself to learn how to debug better and faster
The way I see it, the more I see the same errors on screen, the easier it will be for me to fix them

Start project

  • To make this work, first I had to set up the TS packages
  • Install dependencies
  • Figure out why TS wasn't running on Node
  • Change tsconfig.json and package.json files
  • Run and see the console.log on Node

Day #1

The main issue was to figure out how to read the input
The logic wasn't that hard to figure out

Day #2 (part 1)

Again, the issues was to use the input data
It took me a little while to find a solution by reading a few forums
The logic was a bit simple, although I was multiplying by 2 at the wrong time
After a few attempts and some console.logs I managed to get the rigth answer

Day #2 (part 2)

After finding the right answer for the amount of bow length needed, I go stuck at finding the amount of ribbon
While browsing for something online, I realised I misread the instructions to how to find the length of bow needed
So, I went back to my previous solution and changed it to the ACTUAL right one

Day #3 (part 1)

Got somewhere figuring out the positions of [x,y] resulting in [41 , -95]

Spent some time trying to figure out what to do with those coordenates

Came across a github repo with a Javascript solution, but the code was hard to understand

Asked chatgpt to explain and 'convert' to Typescript

Learned to create a new Set() (https://www.typescriptlang.org/docs/handbook/utility-types.html) and Set.prototype.add() (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add) unique elements to the new Set

Also learned I can use Set.prototype.size to count how many unique elements are there in the Set

Day #3 (part 2)

Found an interesting video on YouTube that discuss the questions of an Advent of Code challenge/puzzle
https://www.youtube.com/playlist?list=PLsCiOxXcx144alYZBBYi62vg95RKvfbIk

Realised I had to split the entries in two Sets

Basically copied and pasted the previous code and added another Set and logic to see who was going where

Learned to 'force' an index in a for...of loop by using destructuring and array.entries()

Got to a point where I have everything right, but don't know how to use the information I have (again) =/

advent-of-code-15's People

Contributors

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