As part of the Sofia hackathon, æternity’s Hans Svensson @hanssv.chain decided to play around with the Advent of Code - an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language.
Hans decided to solve the puzzles using Sophia - find his Day 1 solution here:
While at the core developer meeting in Sofia someone challenged me with the question whether it would be possible to solve the Advent of Code problems using Sophia. At first I discarded the idea since FATE is optimized to run transactions, not programming puzzles, but I am not one to dodge a challenge so in a quiet evening I gave it a go… Each day until Christmas Day there is a two-staged puzzle presented at 6 AM CET.
Here is my solution to day 1 , the first day’s puzzle was rather straightforwa…
As always, he’s been so quick and solved a bunch of challenges in just a few days:
The second problem introduce the Intcode virtual machine, where a sequence of integers should be interpreted as op-codes and arguments. The first version of this machine only does add and mul but I have a feeling this machine will come back in later problems. The first half of the puzzle was trivial, the second half took ages to compute (not to implement). But after I had up:ed the gas limit and split the setup of the Intcode machine memory into setup and initialization it can be run in about 20…
The fourth problem was about checking integer “passwords” for some somewhat strange properties. The straightforward solution looping over all integers and checking them one by one worked. But it was really slow (upwards of two minutes) - so in the end I decided to use one of the properties (digits must be increasing) to skip over many integers at the same time. This improved the solution a lot, and it now even fits in a single block (5.7M gas) and runs in about half a second.
My solution is her…
The sixth problem included a fairly
simple graph/tree problem. In the first part you were supposed to find the
total depth of all nodes in the tree and in the second part you had to find the
common ancestor of two nodes and calculate the distance between them (through
that common ancestor).
This problem showed a shortcoming of Sophia, we are missing some functions on
string, to handle the raw input data we would have needed String.split
which is not yet there . So
we did some preprocessin…
More to come soon!
Best,
Albena
2 Likes