Giter Club home page Giter Club logo

adventofcode2023's Introduction

Advent Calendar 2023

Participate in Advent of code

This contains my solutions for Advent of code 2023. Solutions are overengineered on purpose as my goal is not to chase stars, but rather to architect the code is such a way that it could theoretically be reused to solve similar problems. The code is not perfect but it's mine ;)!

Features

I learnt my lesson fromt last year having to write a bunch of boilerplate code which removed a lot of the fun and added a lot of friction to actually solving the problems.

  • The ability to automatically grab the day's input
  • Unit tests for every problem including the sample data given to everyone
  • I've created a generator class to create all the boiler plate code I need for solving problems in my own framework.
  • This includes creating the InputParser interface and class and the Solver for the day.
  • Thie includes creating the tests that I use to test the sample input and then add the results of the day to.

New From 2023

  • Replaced the Moq testing framework with FakeItEasy

How to Use

If you want to go ahead and use this as a starting framework to solve your own advent of code 2023 there are a few steps to follow:

  1. Add your session key to the adventofcode.json how do I find my session cookie?
  2. Configure the SolverGeneratorConfig.json with the correct information for the day.

How do I use the solution generator?

There are three important variables in SolverGeneratorConfig.json file.

  1. Day The day you want to generate the boilerplate code fore
  2. InputParserModelNamespace The namespace in the project that contains your desired input formate.
  3. InputParserClassName The name of the class that you want to format your input in

Example

Say in my main project I have the following class:

namespace AdventOfCode2023.Models
{
    public class Input
    {
        Guid Key { get; set; }
    }
}

To generate the boilerplate for this input (say on day 10) I would have

{
  "Day": 10,
  "InputParserModelNamespace": "AdventOfCode2023.Models",
  "InputParserClassName": "Input"
}

The output would be the following

Day10/IDayTenInputParser.cs

using AdventOfCodeClient.Interfaces.Parsers;
using AdventOfCode2023.Models;

namespace AdventOfCode2023.Solver.day10
{
	public interface IDayTenInputParser : IInputParser<Input>
	{
	}
}

Day10/DayTenInputParser.cs

using AdventOfCode2023.Models;
using AdventOfCodeClient.Parsers;

namespace AdventOfCode2023.Solver.day10

{
	public class DayTenInputParser : BaseInputParser<Input>, IDayTenInputParser
	{
		public override Input Parse(string input)
		{
			// Insert code here that parses the input
			throw new MissingMethodException();
		}
	}
}

Day10/DayTenSolver.cs

using AdventOfCodeClient.interfaces;
using AdventOfCodeClient.Solvers;
using AdventOfCode2023.Models;

namespace AdventOfCode2023.Solver.day10
{
	public class DayTenSolver : BaseSolver<Input>
	{
		public DayTenSolver(IProblemInputReader problemInputReader, IProblemOutputSender problemOutputSender, IDayTenInputParser inputParser):
			base(problemInputReader, problemOutputSender, inputParser)
		{
		}

		public override int Day => 10;

		public override string SolvePartOne(Input input)
		{
			// Insert code here that solves part one of the problem
			throw new MissingMethodException();
		}

		public override string SolvePartTwo(Input input)
		{
			// Insert code here that solves part two of the problem
			throw new MissingMethodException();
		}
	}
}

How do I find my session cookie?

Google Chrome:

  • Go to adventofcode.com
  • Make sure you are logged in
  • Right click and select "Inspect"
  • Select the "Application" tab
  • In the tree on the left, select "Storage" โ†’ "Cookies" โ†’ "https://adventofcode.com"
  • You should see a table of cookies, find the row with "session" as name
  • Double click the row in the "Value" column to select the value of the cookie
  • Press CTRL + C or right click and select "Copy" to copy the cookie
  • Paste it into your configuration file or on the command line

Feel free to open any issues if you find any though since this is a personal project I can't make any promises to when I will get to them.

Thanks for visiting!

adventofcode2023's People

Contributors

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