A framework to solve Advent of Code problems using ABAP.
- This framework uses RAP so I guess you need an S/4 system. I developed it in our playground system (S4HANA ON PREMISE 2023, SAP_BASIS 758)
- abapgit
- System must be able to make HTTP calls to the outer world (to fetch data from
https://adventofcode.com/) - Each participant needs an account on https://adventofcode.com/
- Install this tool in your S/4 system using abapgit in a local package (e.g.
$ADVENTOFCODE). If you have certificate problems withABAPGITit is probably easiest to download the repository as a ZIP and import the ZIP inABAPGIT. - In
/n/IWFND/V4_ADMINpublish the service groupZUI_AOC_RUNNER
- Extract your session cookie:
You only need the highlighted hex string aftersession=and before; - Create your own local package where the puzzle classes will be generated. Since each year will have up to 25 ABAP classes it might make sense to create a local package for each user and year (e.g.
$AOC2025_MARC). - Open the
Participantentity preview in the service bindingZUI_AOC_RUNNER. Create a new entry with the year number you want to solve (e.g.2025), the package created for your solutions (e.g.$AOC2025_MARC, not$ADVENTOFCODE) and your auth cookie for the AoC page. - On the detail page of this new
Participantyou can now add the days you want to solve (maybe create them one at a time). InEditmode create a newDayentry and pass the day number (1-25). When pressingSavethe ABAP AoC Runner automatically downloads your puzzle input and creates a classZCL_AOC_[SAPUSER]_[YEAR]_[DAY](e.g.ZCL_AOC_MARC_2025_01).
-
Open the newly generated solver class in Eclipse.
-
Replace the dummy implementation of the solver methods with your real implementation. The puzzle input (a
string_table) is passed to both methods. Here is a sample implementation of 2025/01 part 1:
-
The solver class contains a local test class that can be filled with the sample input from the AoC page. It can be executed by Ctrl + Shift + F10 or right-clicking your solver class and selecting
Run As > ABAP Unit Test. Here is a sample test implementation of 2025/01:
-
The solver class is runnable via F9 and executes
solve_part1andsolve_part2and prints the result to the Eclipse console. This result can be entered on the AoC webpage to gain stars.
I am not an ABAP pro so my framework might need some tweaking. I am very open to suggestions and pull requests.
- Other users should not see everones auth cookies (until then please don't abuse others auth cookies 😵)
- Update counter of "Problems solved" in Participants entity when user marks individual Days as solved