Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Developer Advocate
Developer Advocate

Hello, fellow Developers!

Have you heard about that challenge called Advent of Code:
"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, mariusobert, iinside, rich.heilman and people from our SAP community (nabheet.madan3, christian.drumm, gregor_brett, 06df0af3e48c4c9fa24523ba8e809782, 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_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:

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:

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