Festive Intervention and Response Protocol for Elf Coding Emergencies v1.0
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.
- 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;
- 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 instdout
.
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:
- The PROGRAM MUST receive PROBLEM DATA via
stdin
. - The PROGRAM MUST accept two arguments:
--part
or-p
, a required argument with values of either1
or2
.--args
or-a
, optional positional arguments*.
- The PROGRAM MUST return the ANSWER followed by a line break via
stdout
. - The ANSWER MAY have more than one line.
- The PROGRAM MUST return an exit code of
0
on successful execution. Any other code is considered an error. - The PROGRAM MAY log a RUNNING TIME followed by a line break via
stdout
after the ANSWER. - The RUNNING TIME MUST be represented the following three elements sepearated by an spaces and ending with a line break:
- It's prefix of
RT
. - it's NUMERIC VALUE.
- It's UNIT in metric prefix followed by
seconds
, OR it's abbreviated symbol followed bys
. Here's a microμ
symbol; you're welcome. - Example:
RT 123 ns
- It's prefix of
- The PROGRAM MUST NOT print other data besides the ANSER and the RUNNING TIME
- The PROGRAM MAY output data in
stderr
. Any data in this stream will be ignored. - 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
.
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