Challenges

Stellar Static

Part 1

While the crew was focused on perfecting the iftar schedule, nobody was watching the navigation console. By the time anyone notices, the ship has drifted dangerously off course and straight into the gravity well of a dead star, a collapsed remnant that hasn't burned in millennia. The only way to fire the thruster override is to recalibrate the navigation array. But when Adel powers it up, the console floods with thousands of old transmissions from the star's dying days: garbled numbers, mismatched frequencies, blank static. Somewhere in that noise are the stable signals he needs.

Each transmission is a line in the format VALUE | MODE_S : MODE_R, where VALUE is a signed integer (possibly with leading zeros), and MODE_S and MODE_R are single uppercase letters representing the send and receive channels. Whitespace is scattered randomly around the |, :, and edges of each line. Some lines are completely blank, just static bursts.

Input Format

  • 2000 to 2500 lines of transmission data.
  • Non-blank lines follow the pattern: VALUE | MODE_S : MODE_R (with arbitrary whitespace).
  • Blank lines are pure noise.

A transmission is stable only when the send and receive channels match (MODE_S == MODE_R). Everything else is interference; discard it along with any blank lines. Keep track of how many stable signals you find; call that count S.

From the example input below: 42 (A=A, valid), -17 (B≠C, invalid), 00007 (D=D, valid), 0 (E=E, valid), 3 (F=F, valid). Four stable signals, so S = 4.

Next, the navigation manual says to convert each stable value into a navigation bit. Take the absolute value of each signal. Any signal whose absolute value is 0 carries no information; discard it. For the rest, check if the absolute value is a prime number: if it is, the bit is 1; otherwise, the bit is 0.

From the example input: |42| = 42 (not prime -> 0), |7| = 7 (prime -> 1), |0| = 0 (discarded), |3| = 3 (prime -> 1). The bit sequence is [0, 1, 1] with length N = 3.

Now for the thruster calibration. The dead star's rotation has shifted all the frequencies, so the manual requires a rotating index. Let shift = S mod 7. For each position i from 1 to N, compute the effective index:

E = ((i + shift - 1) mod N) + 1

Then build up the Power Index starting from 0:

  • If the bit at position i is 1, add E * E to the Power.
  • If the bit is 0, subtract gcd(E, N) from the Power.

Example Input

  42 | A : A
 -17 | B : C
  00007 | D : D
  0 | E : E
  3  |  F :  F

Example Walkthrough

From the example: S = 4, shift = 4 mod 7 = 4, N = 3, bits = [0, 1, 1].

i=1: E = ((1+4-1) mod 3)+1 = 2. Bit is 0 -> subtract gcd(2, 3) = 1. Power = -1. i=2: E = ((2+4-1) mod 3)+1 = 3. Bit is 1 -> add 33 = 9. Power = 8. i=3: E = ((3+4-1) mod 3)+1 = 1. Bit is 1 -> add 11 = 1. Power = 9.

What is the Power Index of the filtered signal array?

Log in with Discord to get your puzzle input and submit answers.