Skip to Content
Technical Articles
Author's profile photo Lars Hvam

Getting ready – Advent of Code 2020

Advent of Code is a yearly virtual event taking place in December. Every day features new programming exercises, which can be solved in your programming language of choice.

Just like Nabheet Madan suggested last year, let’s do this in ABAP!

Advent%20of%20Code

Advent of Code

 

ABAP Template

I will be sharing my solutions on GitHub, in preparation I’ve made a template which can be used:

https://github.com/larshp/abap-advent-2020-template

Click “Use this template” to clone all the code to your own repository.

 

Renaming

To avoid name clashes, there is an option to automagically rename all objects in the repository(including code references), first adjust the rename settings in abaplint.json,

abaplint.json

abaplint.json

And run:

npm install && npm run rename

 

Additional Features

 

As preparation I did a few of the first exercises from last year, see https://github.com/larshp/abap-advent-2019

 

When the event starts, feel free to share links to your GitHub repositories in the comments below 🙂

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Oleg Bashkatov
      Oleg Bashkatov

      Very nice! Thank you!

      Would you mind if I do the same but for another project:

      https://projecteuler.net/

      ?

      Let’s do task in ABAP.

      Moreover for project euler sometimes it is needed to do task ABAP+ C/C++/Python which are on the Linux machine. It is interesting but sometimes is not applicable for production use.

       

      as for renaming: seems really interesting. Thank you!
      does that mean that I could upload from gitHub solution with different namespace? Is there vice a versa naming?

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      Feel free to use it for whatever ?

      Renaming, yea, and vice versa, the rename rules are regex based, but takes care of references to some extend, currently it works somewhat for CLAS and INTF. Just copy the files to your local PC and then run the renaming.

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      Make sure to keep the template updated, things change ? Issues/questions/comments welcome in the template repository here, or in the abapGit slack(invite linked from abapgit readme)

       

      Follow my progress at https://github.com/larshp/abap-advent-2020

      Author's profile photo Jörgen Lindqvist
      Jörgen Lindqvist

      Yes, that helped and I think broke something as well... I ran into all kinds of troubles ?

      For instance, when I got started on part 2 my output/index.js got its global.abap.initDB() split on two lines, so wouldn't run. Fixed that manually each run.

      Also, I never manage to get the READ TABLE working properly reading lines with "KEY table_line = blah"... Same with table assignments. And when trying to bypass that with a local TYPE to get a structure with a named component, the downport put the DATA before the TYPES, so that didn't go well either...

      Furthermore, i would expect these two lines to return the same result.

      lv_2020_difference = 2020 - lv_first_factor - lv_second_factor.
      lv_2020_difference = 2020 - ( lv_first_factor + lv_second_factor ).
      

      But the first line actually becomes

      lv_2020_difference.set(constant_2020.minus(lv_first_factor.minus(lv_second_factor)));

      ...which obviously is not the same thing. I guess I should report that to abaplint if it's not already there...

       

      This is so much fun! ?

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      Yea, its gonna be a challenge 🙂 But traceable since it builds the files in the local folders.

      There is an open issue for the associativity, https://github.com/abaplint/transpiler/issues/28

      TYPES and DATA, guess thats an error in the quick fix for https://rules.abaplint.org/definitions_top/, can you help opening an issue for it on github?

      Author's profile photo Jörgen Lindqvist
      Jörgen Lindqvist

      You beat me to it 🙂