Giter Club home page Giter Club logo

adventofcode2022's Introduction

AdventOfCode2022

This is my take on the Advent of Code challenge 2022 https://adventofcode.com/

Being an ABAPer, this is of course in ABAP.

Enjoy!

Files:

zcl_lc_adv2022.abap -> Helper class for daily challenges.

zlc_advent22_day1.abap -> Day 1 challenge. In this report I leveraged ABAP internal tables and let them do the work. The working table is a sorted table with the unique key being an elf number that is incremented on every empty line in the puzzle input. The number of calories is simply aggregated using the COLLECT ABAP statement. The resulting aggregated data is then sorted by calories to identify the one(s) with the most calories.

zlc_advent22_day2.abap -> Day 2 challenge. Don't look for a clever solution in this one. I approached this challenge pragmatically with basic string parsing, case statements and a few ternary operators.

zlc_advent22_day3.abap -> Day 3 challenge. Some more basic string processing to solve this one.

zlc_advent22_day4.abap -> Day 4 challenge. For the first part of this challenge I wanted to use the OVERLAY keyword in ABAP that I stumbled accross while looking for something else. To make use of OVERLAY I built very visual string representations of the ranges and overlayed one on top of the other. If the resulting string is the same with the overlay as it was before, the second string is fully contained in the first one. For the second part (partial overlap) I simply inserted in an internal table with a unique key all numbers of the first range. With that done, I inserted the numbers of the second range. As soon as inserting a number of the second range raises an error, there is an overlap.

zlc_advent22_day5.abap -> Day 5 challenge. That one was also achieved with simple internal tables manipulations. The biggest challenge was the parsing of the input. It would have been probably easier with other languages, but my goal is to complete as much challenges as possible with ABAP.

zlc_advent22_day6.abap -> Day 6 challenge. Yet another one achieved with the use of an internal table with a unique key. As soon as one of the characters in the sequence is not unique (SY-SUBRC = 4 after inserting the character) the loop is stoped, and we move on to the next input character.

zlc_advent22_day8.abap -> Day 8 challenge. Navigating the trees using a table of table of integers to simulate an array. Trees (elements of the array) are adressed directly using array[row][col] instead of typical READ or LOOP statements.

zlc_advent22_day10.abap -> Day 10 challenge. Another string manipulation exercise with local data structures, ternary operator. The RENDER_SCREEN method returns a table with all screen rows, passed by value. For performance reasons, this would be a big NO in normal circumstances, but for an exercise like this, I'm ok with it.

zlc_advent22_day11.abap -> Day 11 challenge. This only includes part 1 with self-managed monkeys. Again, super ugly parsing of the input table but everything else is self-explanatory simple.

adventofcode2022's People

Contributors

chaliluc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.