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
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) 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:
…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)