Giter Site home page Giter Site logo

solidworx / adventofcode-template Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 5 KB

Template to assist running code for AdventOfCode challenges

PHP 100.00%
advent-of-code advent-of-code-2017 adventofcode adventofcode2017 advent-of-code-template adventofcode-template challenge

adventofcode-template's Introduction

AdventOfCode Template

This is a simple template project for the AdventOfCode project in PHP. The goal of this template is to give people a simple way to test your code against the AdventOfCode samples, and an easy way to group and run your code

Usage

You need create your own copy of this repository in order to add the code for your challenges. Getting a copy can be done by either forking or cloning this repository.

You will also need composer in order to install the required dependencies to run your code.

Once you have a copy of the repository, you can hen add all the code for your challenges in the respective directories. All challenge code lives inside the src directory, and is grouped by day. Each part has a separate file where the code needs to be added to complete the challenge.

Each day directory consists of a few files:

  • part1.php - The code to complete part 1 of the challenge
  • part2.php - The code to complete part 2 of the challenge
  • test.php - This is the sample input and results which can be used to run against your code. (This files needs to return an array, which consists of two values, an array for the input => result for part 1, and an array with the input => result for part 2)
  • input.txt - This is where you can add your unique input per challenge to be run against your code. This input will be run against the code in both part1.php and part2.php

After cloning the repository, you can add your code to complete the challenge to the relevant file.

Running your code

This project comes with a CLI script that you can run to execute your code. In order to run the code for all the challenges, execute the bin/advent command:

$ bin/advent

This will run all your code with your custom input for all the challenge days. It will run both part 1 and part 2 of each day.

Running only a specific day

If you only want to run a specific day, add the day you want to run as an argument to the CLI command, E.G:

$ bin/advent day12

Running the test input against your code

If you would like to run the sample input against your scripts to test your code with the expected result, you can pass the --test flag to the command:

$ bin/advent --test

Or run the tests for a specific day:

$ bin/console day12 --test

This will run the samples against your code, as well as your unique input and give you the resul

Getting the input in each script

To get your unique input in each script, you can use the special getInput function. This function will return either your unique input for the specific date, or it will return the sample input if you used the --test flag. In all cases, the result of calling the getInput function will give you valid input to code against.

Contributing

All the sample input of each day and both parts of each day needs to be kept up to date in this repository. If you have unlocked the second part of any day, and the sample input for that day is not yet added to this repository, then please open a PR to add the sample input.

Any other improvements or features is also welcome.

adventofcode-template's People

Contributors

pierredup avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

pierredup

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.