Skip to content

gambit-consulting/abap-aoc-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABAP AoC Runner

A framework to solve Advent of Code problems using ABAP.

Prerequisites

  • 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/

Installation

  1. Install this tool in your S/4 system using abapgit in a local package (e.g. $ADVENTOFCODE). If you have certificate problems with ABAPGIT it is probably easiest to download the repository as a ZIP and import the ZIP in ABAPGIT.
  2. In /n/IWFND/V4_ADMIN publish the service group ZUI_AOC_RUNNER

    image

Usage

Preparation

  1. Extract your session cookie: image
    You only need the highlighted hex string after session= and before ;
  2. 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).
  3. Open the Participant entity preview in the service binding ZUI_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.
  4. On the detail page of this new Participant you can now add the days you want to solve (maybe create them one at a time). In Edit mode create a new Day entry and pass the day number (1-25). When pressing Save the ABAP AoC Runner automatically downloads your puzzle input and creates a class ZCL_AOC_[SAPUSER]_[YEAR]_[DAY] (e.g. ZCL_AOC_MARC_2025_01).

Solving

  1. Open the newly generated solver class in Eclipse.

  2. 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:

    image

  3. 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:

    image

  4. The solver class is runnable via F9 and executes solve_part1 and solve_part2 and prints the result to the Eclipse console. This result can be entered on the AoC webpage to gain stars.

Caution

I am not an ABAP pro so my framework might need some tweaking. I am very open to suggestions and pull requests.

To-Dos

  • 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors