January 23, 2026

Solution for Codyssi 2025 - Compass Calibration

Link to the puzzle text

Part 1

In this puzzle we are given a file containing a list of number and a series of + and - characters. The characters represent the sign of the numbers in the list and we should sum up all the signed numbers.

We used the zip function to iterate over both the numbers and the signs concurrently. Then we turned the number negative whenever the sign was a -. Finally we summed up all the numbers.

Part 2

In part 2, the given series of + and - characters should be reversed before using them to determine whether a number is negative.

We reused the previous code and during the call to zip, we instead supply the reversed list of characters. The rest of the code was the same. 

Part 3

In part 3 the list of numbers are now parts of 2-digit numbers instead. So the first two entries form a single number, the next two entries form the next numbers and so on. The signs now apply to the 2-digits numbers and we should still sum them up.

We again could reuse most of the code. By zipping the list of digits in two increments starting from 0 and from 1, we could get the pairs of entries to transform into the larger numbers:

paired_offsets = [10*a + b for a, b in zip(offsets[::2], offsets[1::2])]

The rest was again the same. 

Link to my solutions

No comments:

Post a Comment