Skip to content

Latest commit

 

History

History
85 lines (64 loc) · 3.39 KB

FIREPLACEv1.0.md

File metadata and controls

85 lines (64 loc) · 3.39 KB

FIREPLACE v1.0

Festive Intervention and Response Protocol for Elf Coding Emergencies v1.0

Introduction

At the heart of the ElfScript Brigade's operational endeavors resides the Fireplace Protocol Version 1.0 (FIREPLACEv1.0), an enchanting and robust communication system. This protocol serves as the magical conduit through which coding elves engage in the exchange of solutions and collaborative efforts to overcome challenges that could potentially dampen the Christmas spirit.

The FIREPLACEv1.0 allows the use of the esb tooling for solving Advent of Code problems.

tl;dr:

  • Problem input comes from stdin;
  • Problem answer goes to stdout;
  • --part, --args goes in the arguments;
  • May output the running time of the program in stdou;
  • stderr is ignored;

Protocol Definition

Premises

  • This protocol is tailored to assist coding elves in solving Advent of Code problems.
  • Each problem consists of PROBLEM DATA, usually stored in a file, and an ANSWER that should effectively solve the problem.
  • The RUNNING TIME of a PROGRAM is the time the program took to execute, starting before parsing stdin data and ending just before returning the answer in stdout.

Requirements

Any PROGRAM implementing FIREPLACEv1.0 should receive the PROBLEM DATA as input and return the ANSWER as an output. The following requirements must be adhered to:

  1. The PROGRAM MUST receive PROBLEM DATA via stdin.
  2. The PROGRAM MUST accept two arguments:
    1. --part or -p, a required argument with values of either 1 or 2.
    2. --args or -a, optional positional arguments*.
  3. The PROGRAM MUST return the ANSWER followed by a line break via stdout.
  4. The ANSWER MAY have more than one line.
  5. The PROGRAM MUST return an exit code of 0 on successful execution. Any other code is considered an error.
  6. The PROGRAM MAY log a RUNNING TIME followed by a line break via stdout after the ANSWER.
  7. The RUNNING TIME MUST be represented the following three elements sepearated by an spaces and ending with a line break:
    1. It's prefix of RT.
    2. it's NUMERIC VALUE.
    3. It's UNIT in metric prefix followed by seconds, OR it's abbreviated symbol followed by s. Here's a micro μ symbol; you're welcome.
    4. Example: RT 123 ns
  8. The PROGRAM MUST NOT print other data besides the ANSER and the RUNNING TIME
  9. The PROGRAM MAY output data in stderr. Any data in this stream will be ignored.
  10. The PROGRAM MAY implement an optional flag --help or -h that shows command usage.

* Some Advent of Code problems have different parameters for tests and for the PROBLEM DATA. As in year 2023 day 21, If that's the case, positional arguments are passed through the --arg.

Examples:

Running programs

cat problem_data.txt | ./my_program --part 1
1234
./my_program --part 1 < problem_data.txt
1234

Running programs with running time

./my_program --part 1 --args a b c < problem_data.txt
1234
RT 7632 milliseconds
cat problem_data.txt | ./my_program --part 2
1234
RT 6833 milliseconds

Problem with three lines answer

./my_program --part 1 --args a b c < problem_data.txt
three
lines
answer