|
1 |
| -# advent-of-code-2022 |
2 |
| -Advent of Code 2022 on the Flipper Zero |
| 1 | +# Advent of Code 2022 x Flipper Zero |
| 2 | + |
| 3 | +## What is this? |
| 4 | + |
| 5 | +Great question! This is a program meant to run on the awesome [Flipper Zero](https://flipperzero.one/) that will calculate the answers to the just as awesome [Advent of Code](https://adventofcode.com/2022) puzzles (2022 edition) graciously offered each year by [Eric Wastl](http://was.tl/). |
| 6 | + |
| 7 | +## Can I run this without a Flipper Zero? |
| 8 | + |
| 9 | +Nope. At least not directly: you would first need to port all the Flipper-specific bits to your environment. |
| 10 | + |
| 11 | +## What language is this in? |
| 12 | + |
| 13 | +C. Github is not lying. I did take advantage of [mlib](https://github.com/P-p-H-d/mlib) to ease the pain, as it is already used in the Flipper Zero firmware. |
| 14 | + |
| 15 | +## What hardware does the Flipper Zero have? |
| 16 | + |
| 17 | +It is based on a [STM32WB55RG](https://www.st.com/en/microcontrollers-microprocessors/stm32wb55rg.html) chip: 32-bit 64 MHz CPU, 256 KB RAM. |
| 18 | + |
| 19 | +However the aim here was to make a program that can be dynamically loaded by a running Flipper (i.e. a [FAP](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppsOnSDCard.md)), and so the actual available memory is closer to 100 KB... Which was the main challenging constraint here (besides working with plain C). |
| 20 | + |
| 21 | +## How fast is it? |
| 22 | + |
| 23 | +Most days are solved fairly quickly (fraction of a second). A few however take a while. Day 23 — part 2, for instance, takes about 20 seconds. Again, the aim here wasn't speed, but simply trying to fit the problem onto the limited space of a Flipper Zero. |
| 24 | + |
| 25 | +## I have a Flipper Zero! How do I run this? |
| 26 | + |
| 27 | +The easiest is to first clone/check out the [official firmware](https://github.com/flipperdevices/flipperzero-firmware) (version [0.75.0](https://github.com/flipperdevices/flipperzero-firmware/releases/tag/0.75.0) would be the one this application was tested with), and then add this here repository as a submodule. |
| 28 | + |
| 29 | +Inside the `flipperzero-firmware` top-level directory: |
| 30 | + |
| 31 | +``` |
| 32 | +$ git submodule add -f https://github.com/itizir/advent-of-code-2022.git applications_user/advent_of_code_2022 |
| 33 | +``` |
| 34 | + |
| 35 | +Follow the instructions on how to build and run [FAPs](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppsOnSDCard.md). For instance |
| 36 | + |
| 37 | +``` |
| 38 | +$ ./fbt COMPACT=1 DEBUG=0 launch_app APPSRC=applications_users/advent_of_code_2022 |
| 39 | +``` |
| 40 | + |
| 41 | +I recommend compiling with those flags indeed (see point about bugs below). |
| 42 | + |
| 43 | +The program will be installed in the `Games` Applications folder. |
| 44 | + |
| 45 | +Then after obtaining puzzle inputs from the [AOC website](https://adventofcode.com/2022), save them as `.txt` files on the Flipper's SD card under `/advent/2022`, naming them after the corresponding day number. E.g. `/advent/2022/13.txt`. |
| 46 | + |
| 47 | +## Is it safe? |
| 48 | + |
| 49 | +The risk of your Flipper [catching fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) because of it is... very low. And it won't steal your grandma's date of birth either. |
| 50 | + |
| 51 | +Still, **use it at your own risk**! |
| 52 | + |
| 53 | +The chances of your Flipper crashing or hanging because of it are high! Especially since most of the solvers simply _assume_ correctly formed input data, and appropriately sized problems, without checking. |
| 54 | + |
| 55 | +## Are there known bugs and issues? |
| 56 | + |
| 57 | +Yes. Just as I was preparing this release, I realised day 14 does not safely run if the release `COMPACT=1` and `DEBUG=0` flags are not used, as the recursion then seems to lead to a stack overflow. I may or may not get round to fixing this. :shrug: |
| 58 | + |
| 59 | +It is also not currently possible to interrupt long calculations (e.g. pressing the 'back' button), which would be a nice addition. |
| 60 | + |
| 61 | +And then obviously there are always _unknown_ bugs and issues... |
| 62 | + |
| 63 | +Please do let me know if you find some, in particular if wrong answers are produced: the puzzle inputs are not all identical for everybody, so there may well be bugs I didn't notice because I was lucky with my input. |
0 commit comments