All Projects → sindrekjr → AdventOfCodeBase

sindrekjr / AdventOfCodeBase

Licence: MIT license
Template repository for solving Advent of Code puzzles, which automatically handles input retrieval and output.

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to AdventOfCodeBase

AoCHelper
Helper .NET library for solving Advent of Code puzzles
Stars: ✭ 22 (-33.33%)
Mutual labels:  advent-of-code, puzzles
adventofcode
Advent of Code solutions 2015-2021
Stars: ✭ 95 (+187.88%)
Mutual labels:  advent-of-code
Apex.Serialization
High performance contract-less binary serializer for .NET
Stars: ✭ 82 (+148.48%)
Mutual labels:  netcore
advent-2020-kotlin
🎄 Advent of Code 2020: Solutions in Kotlin
Stars: ✭ 37 (+12.12%)
Mutual labels:  advent-of-code
CellReport
CellReport 是一个netcore实现的、以复杂统计报表为核心目标的制作、运行工具。支持数据看板、大屏制作。你可以使用数据库、excel文件、api服务、已有报表等为数据源,通过内置的集合函数组织数据,以类excel界面设计最终呈现结果。
Stars: ✭ 196 (+493.94%)
Mutual labels:  netcore
h5
🚀 The next generation C# to JavaScript compiler
Stars: ✭ 97 (+193.94%)
Mutual labels:  netcore
InfluxDB.Client.Net
A C# client object model to help integrate with InfluxDB with CLI languages. Supports both .Net traditional and .Net Core.
Stars: ✭ 95 (+187.88%)
Mutual labels:  netcore
advent-of-code-2019
Advent of Code 2019 Submissions
Stars: ✭ 27 (-18.18%)
Mutual labels:  advent-of-code
Decor.NET
A simple way to decorate a class with additional functionality using attributes.
Stars: ✭ 29 (-12.12%)
Mutual labels:  netcore
Portable-WebDAV-Library
Moved to codeberg.org - https://codeberg.org/DecaTec/Portable-WebDAV-Library - The Portable WebDAV Library is a strongly typed, async WebDAV client library which is fully compliant to RFC 4918, RFC 4331 and "Additional WebDAV Collection Properties". It is implemented as .NETStandard 1.1 library in oder to be used on any platform supporting .NETS…
Stars: ✭ 45 (+36.36%)
Mutual labels:  netcore
doteasy.rpc
Inspired by microservices, a lightweight framework that looks like a rabbit, based on NET Core 2.0 Standard 2 core library
Stars: ✭ 62 (+87.88%)
Mutual labels:  netcore
horusec-engine
Horusec analysis engine
Stars: ✭ 18 (-45.45%)
Mutual labels:  netcore
Cauldron
C# Toolkit
Stars: ✭ 68 (+106.06%)
Mutual labels:  netcore
Meadow
Integrated Ethereum implementation and tool suite focused on Solidity testing and development.
Stars: ✭ 126 (+281.82%)
Mutual labels:  netcore
EFSqlTranslator
A standalone linq to sql translator that can be used with EF and Dapper.
Stars: ✭ 51 (+54.55%)
Mutual labels:  netcore
ProtobufDecoder
A Google Protocol Buffers (Protobuf) payload decoder/analyzer
Stars: ✭ 33 (+0%)
Mutual labels:  netcore
Miniblog.Core.W3C
MiniBlog + ASP.NET Core + W3C.CSS
Stars: ✭ 26 (-21.21%)
Mutual labels:  netcore
awesome-adventjs
🎅🎄 A collection of awesome resources related to the adventJS challenge https://adventjs.dev by @midudev
Stars: ✭ 45 (+36.36%)
Mutual labels:  advent-of-code
Awesome-Nuget-Packages
📦 A collection of awesome and top .NET packages sorted by most popular needs.
Stars: ✭ 87 (+163.64%)
Mutual labels:  netcore
comcms
COMCMS_Core 版本
Stars: ✭ 32 (-3.03%)
Mutual labels:  netcore

AdventOfCodeBase

Template project for solving Advent of Code in C#, running on .NET 6.0.

Features

  • Simple configuration with config.json.
  • Fetches puzzle input from adventofcode.com and stores it locally.
  • Supports easily switching between debug-input and real input.
  • Naive benchmarking, showing as millisecond count.

Usage

Creating a repository

To get started using this template, click the green "Use this template" button above (or this link) to create a new repository of your own from it.

If any solution files that you need are not already included, see Generating Previous Year's Solution Files.

Configuring

Create a new file named config.json at the root of the project.

{
  "cookie": "c0nt3nt",
  "year": 2020,
  "days": [0] 
}

If you run the program without adding this file, one will be created for you without a cookie field. The program will not be able to fetch puzzle inputs from adventofcode.com before a valid cookie is added to the configuration.

cookie - Note that c0nt3nt must be replaced with a valid cookie value that your browser stores when logging in at adventofcode.com. Instructions on locating your session cookie can be found here: wimglenn/advent-of-code-wim#1

year - Specifies which year you wish to output solutions for when running the project. Defaults to the current year if left unspecified.

days - Specifies which days you wish to output solutions for when running the project. Defaults to current day if left unspecified and an event is actively running, otherwise defaults to 0.

The field supports list comprehension syntax and strings, meaning the following notations are valid.

  • "1..4, 10" - runs day 1, 2, 3, 4, and 10.
  • [1, 3, "5..9", 15] - runs day 1, 3, 5, 6, 7, 8, 9, and 15.
  • 0 - runs all days

Running the project

Write your advent of code solutions in the appropriate solution classes, AdventOfCode.Solutions/Year<YYYY>/Day<DD>/Solution.cs.

Then run the project. From the command line you can use dotnet run, and optionally specify a day inline. For example, to run your solution for day 21:

dotnet run 21

Example solution

class Solution : SolutionBase
{
    // the constructor calls its base class with (day, year, name)
    public Solution() : base(02, 2021, "The Big Bad Sample Santa")
    {
        // you can use the constructor for preparations shared by both part one and two if you wish
    }
    
    protected override string SolvePartOne()
    {
        var lines = Input.SplitByNewline();
        return lines.First();
        // this would return the first line of the input as this part's solution
    }
    
    protected override string SolvePartTwo()
    {
        Debug = true;
        // we choose to use the debug input for this part
        // note that the debug input cannot be fetched automatically; it has to be copied into the solution folder manually
        return "";
    }
}

Notes

Generating Previous Year's Solution Files

Use the included PowerShell script GenerateSolutionFiles.ps1 to generate a year's solution files following the same layout as those already included.

Usage: GenerateSolutionFiles.ps1 [-Year <Int>]

If no value is provided it will generate files for the current year. The script will avoid overwriting existing files.

Requires PowerShell v3 or later due to the way $PSScriptRoot behaves. If you have Windows 8+ you should be set. Upgrades for previous versions, and installs for macOS and Linux can be found in Microsoft's Powershell Documentation

Automatic Debugger Break On Exception

When running your Solutions with a Debugger attached e.g. VSCode or Visual Studio the BaseSolution base class will try to pause/break the debugger when there is an uncaught Exception thrown by your solution part. This allows for inspection with the debugger without having to specifically set-up additional exception handling within the debugger or your solution.

Background

I intended to use Advent of Code 2019 to learn C#, and found that I wanted to try to put together a small solutions framework of my own. In that way this template came about as an introductory project to C# and .NET Core.

Contributing

If you wish to contribute to this project, simply fork and the clone the repository, make your changes, and submit a pull request. Contributions are quite welcome!

Please adhere to the conventional commit format.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].