Skip to Content
Event Information

#AdventOfCode Challenge 2019. Are you in?

Hello, fellow Developers!

Have you heard about that challenge called Advent of Code: https://adventofcode.com/2019?

“Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.” as its author Eric Wastl explains.

While it is nothing SAP-specific, my teammates from SAP Developer Advocates team DJ Adams, Marius Obert, Maximilian Streifeneder, Rich Heilman and people from our SAP community (Nabheet Madan, Christian Drumm, Gregor Brett, Leo van Hengel, Hendrik Neumann to mention those I am aware of) joined it.

Because the requirements are simple: you love to code, you love to have fun, you love to learn. Do you feel like all these are close to your heart? Then join and let us know in comment! Already participating, but not listed above? Please let us know in the comments as well!

You can use whatever programming language or tool you know or you want to learn. Maxi is using Java, Nabheet is using ABAP, Gregor is using Elixir, Rich used HANA SQLScript, while I am using Python and … SAP Data Hub, dev edition.

Why SAP Data Hub?

Because … why not. Yes, it is overkill. But — as I mentioned — the idea is to learn and to have fun.

If you watch that great talk of Eric from two weeks ago (and it is must-watch for many reasons), then you hear about people using Excel, Google Sheets, Minecraft and even paper to solve those puzzles. 🙂

So, here is my solution of the first puzzle from day 2 using Data Hub:

…with the following code for the Python3 operator

def on_input(data_in):
    data= data_in
    intcode_str = data.rstrip().split(',')
    intcode_str[1:3]=['12','2']
    intcode_int = list(map (int, intcode_str))
    
    result = intcode_int
    cursor = 0
    while result[cursor] != 99:
        result[result[cursor+3]] = result[result[cursor+1]] + result[result[cursor+2]] if result[cursor]==1 else result[result[cursor+1]] * result[result[cursor+2]]
        cursor += 4

    api.send("result", result[0])
    
api.set_port_callback("input", on_input)

You can import the complete data pipeline code from my GitHub repo: https://github.com/Sygyzmundovych/AdventOfCode2019/blob/master/02/mine.vital.aoc.2019.02.01.json

Let’s start the pipeline.

Open the Terminal’s UI once the pipeline is running. Provide the input from the puzzle, which for me was:

1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,5,19,23,2,10,23,27,1,27,5,31,2,9,31,35,1,35,5,39,2,6,39,43,1,43,5,47,2,47,10,51,2,51,6,55,1,5,55,59,2,10,59,63,1,63,6,67,2,67,6,71,1,71,5,75,1,13,75,79,1,6,79,83,2,83,13,87,1,87,6,91,1,10,91,95,1,95,9,99,2,99,13,103,1,103,6,107,2,107,6,111,1,111,2,115,1,115,13,0,99,2,0,14,0

…and get the result 4714701 received from the Python operator and displayed in the Terminal.

Are you in?

Should you be joining that challenge (not necessarily for the sake of leaderboard, but for the sake of knowledge, fun and support) or already joined — let us know in the comment. And do not forget to include links to your code, to your blog posts, or other online resources you created for this year’s Advent of Code, no matter languages or tools you are using!


Happy coding ⌨️
-Vitaliy (aka @Sygyzmundovych)

1 Comment
You must be Logged on to comment or reply to a post.
  • Nice one Witalij. I just wanted to highlight a couple of things for folks here:

    • if you want to join a friendly chat on this subject amongst like-minded individuals in the SAP dev ecosphere, you can head on over to the #adventofcode channel on the “SAP Mentors and Friends” Slack workspace (if you’re not on there already, you can find an invite link here)
    • This Friday (i.e. TOMORROW, 06 Dec 2019), at the time of writing!) the #HandsOnSAPDev episode will be on this very subject, with two special guests from the community – Hendrik Neumann and Gregor Wolf– showing us some of their ABAP and SAP Cloud Platform functions based solutions to the puzzles … see https://bit.ly/handsonsapdev#upcoming for info

    Happy hacking!