2021 / Day 19

Beacon Scanner

Read the original puzzle on adventofcode.com ↗

The solution

C11

solution.c

1#include "aoc.h"
2
3/* The local input is 10204 bytes, 780 lines, longest line 18. There are 28
4 * scanners, 25 to 27 beacons each, coordinates -984 through 962. SCANNERS = 64
5 * and BEACONS = 64 bound pairwise distance tables. Shared sorted squared
6 * distances screen scanner pairs before testing the 24 proper rotations.
7 * Translation vote counts are followed by an exact 12-beacon overlap check.
8 * Require the graph of pairwise 12-overlaps to connect to scanner zero. */
9
10static slice line(slice s, size_t *p) {
11    size_t b = *p;
12    while (*p < s.l && s.p[*p] != '\n') {
13        (*p)++;
14    }
15    size_t e = *p;
16    if (*p < s.l) {
17        (*p)++;
18    }
19    if (e > b && s.p[e - 1] == '\r') {
20        e--;
21    }
22    return (slice){s.p + b, e - b};
23}
24
25static uint64_t number(slice s, size_t *p, uint64_t limit) {
26    aoc_assert(*p < s.l && s.p[*p] >= '0' && s.p[*p] <= '9', "bad number");
27    uint64_t n = 0;
28    while (*p < s.l && s.p[*p] >= '0' && s.p[*p] <= '9') {
29        uint64_t d = s.p[(*p)++] - '0';
30        aoc_assert(d <= limit && n <= (limit - d) / 10, "number out of range");
31        n = n * 10 + d;
32    }
33    return n;
34}
35
36static int64_t signed_number(slice s, size_t *p, int64_t limit) {
37    int32_t neg = *p < s.l && s.p[*p] == '-';
38    if (neg) {
39        (*p)++;
40    }
41    int64_t v = (int64_t)number(s, p, (uint64_t)limit);
42    return neg ? -v : v;
43}
44
45static void literal(slice s, size_t *p, const char *t) {
46    size_t n = strlen(t);
47    aoc_assert(*p <= s.l && n <= s.l - *p && memcmp(s.p + *p, t, n) == 0,
48               "bad syntax");
49    *p += n;
50}
51
52static int32_t abs32(int32_t x) {
53    return x < 0 ? -x : x;
54}
55
56static int cmp64(const void *a, const void *b) {
57    int64_t x = *(const int64_t *)a, y = *(const int64_t *)b;
58    return (x > y) - (x < y);
59}
60
61enum {
62    SCANNERS = 64,
63    BEACONS = 64,
64    PAIRS = BEACONS * (BEACONS - 1) / 2,
65    HASH = 8192,
66    COORD = 1000000,
67    GLOBAL = 100000000,
68    WORK = 20000000
69};
70
71typedef struct {
72    int32_t x, y, z;
73} Point;
74
75static Point points[SCANNERS][BEACONS], positions[SCANNERS], votes[HASH],
76    all[SCANNERS * BEACONS];
77static uint16_t counts[HASH];
78static int64_t distances[SCANNERS][PAIRS];
79static int32_t sizes[SCANNERS], ns, work;
80static uint8_t known[SCANNERS];
81
82static int32_t same(Point a, Point b) {
83    return a.x == b.x && a.y == b.y && a.z == b.z;
84}
85
86static Point sub(Point a, Point b) {
87    return (Point){a.x - b.x, a.y - b.y, a.z - b.z};
88}
89
90static Point plus(Point a, Point b) {
91    a.x += b.x;
92    a.y += b.y;
93    a.z += b.z;
94    aoc_assert(abs32(a.x) <= GLOBAL && abs32(a.y) <= GLOBAL &&
95                   abs32(a.z) <= GLOBAL,
96               "aligned coordinate exceeds 100000000");
97    return a;
98}
99
100static Point rotate(Point p, int32_t r) {
101    static const uint8_t perm[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
102                                       {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
103    static const int32_t parity[6] = {1, -1, -1, 1, 1, -1};
104    int32_t a[3] = {p.x, p.y, p.z};
105    int32_t k = r / 4, sx = (r & 1) ? -1 : 1, sy = (r & 2) ? -1 : 1;
106    return (Point){a[perm[k][0]] * sx, a[perm[k][1]] * sy,
107                   a[perm[k][2]] * sx * sy * parity[k]};
108}
109
110static int cmp_point(const void *a, const void *b) {
111    const Point *x = a, *y = b;
112    if (x->x != y->x) {
113        return (x->x > y->x) - (x->x < y->x);
114    }
115    if (x->y != y->y) {
116        return (x->y > y->y) - (x->y < y->y);
117    }
118    return (x->z > y->z) - (x->z < y->z);
119}
120
121static inline __attribute__((always_inline)) void
122check_unique_beacon(int32_t current, Point *v_ref) {
123    for (int32_t i = 0; i < sizes[current]; i++) {
124        aoc_assert(!same((*v_ref), points[current][i]), "duplicate beacon");
125    }
126}
127
128static inline __attribute__((always_inline)) int32_t
129record_beacon_distances(int32_t i, int32_t n, int32_t a) {
130    for (int32_t b = 0; b < a; b++) {
131        Point d = sub(points[i][a], points[i][b]);
132        distances[i][n++] =
133            (int64_t)d.x * d.x + (int64_t)d.y * d.y + (int64_t)d.z * d.z;
134    }
135
136    return n;
137}
138
139static inline __attribute__((always_inline)) int32_t
140build_scanner_distances(int32_t i, int32_t n) {
141    for (int32_t a = 0; a < sizes[i]; a++) {
142        n = record_beacon_distances(i, n, a);
143    }
144
145    return n;
146}
147
148static void parse(slice s) {
149    ns = 0;
150    memset(known, 0, sizeof known);
151    size_t p = 0;
152    int32_t current = -1;
153    while (p < s.l) {
154        slice l = line(s, &p);
155        if (!l.l) {
156            continue;
157        }
158        size_t q = 0;
159        if (l.p[0] == '-' && l.l > 3 && l.p[1] == '-') {
160            aoc_assert(ns < SCANNERS, "too many scanners");
161            literal(l, &q, "--- scanner ");
162            aoc_assert(number(l, &q, SCANNERS - 1) == (uint64_t)ns,
163                       "scanner IDs must be consecutive");
164            literal(l, &q, " ---");
165            current = ns++;
166            sizes[current] = 0;
167        } else {
168            aoc_assert(current >= 0 && sizes[current] < BEACONS,
169                       "too many beacons or missing scanner");
170            Point v;
171            v.x = (int32_t)signed_number(l, &q, COORD);
172            literal(l, &q, ",");
173            v.y = (int32_t)signed_number(l, &q, COORD);
174            literal(l, &q, ",");
175            v.z = (int32_t)signed_number(l, &q, COORD);
176            check_unique_beacon(current, &v);
177            points[current][sizes[current]++] = v;
178        }
179        aoc_assert(q == l.l, "bad scanner input");
180    }
181    aoc_assert(ns > 0, "empty scanners");
182    for (int32_t i = 0; i < ns; i++) {
183        aoc_assert(sizes[i] > 0, "empty scanner");
184        int32_t n = 0;
185        n = build_scanner_distances(i, n);
186        qsort(distances[i], (size_t)n, sizeof(int64_t), cmp64);
187    }
188    known[0] = 1;
189    positions[0] = (Point){0};
190    work = 0;
191}
192
193static inline __attribute__((always_inline)) int32_t
194rotate_scanner_points(int32_t b, int32_t i, int32_t r, Point rotated[BEACONS]) {
195    for (i = 0; i < sizes[b]; i++) {
196        rotated[i] = rotate(points[b][i], r);
197    }
198
199    return i;
200}
201
202static inline __attribute__((always_inline)) uint32_t
203find_translation_slot(Point d, uint32_t h) {
204    while (counts[h] && !same(votes[h], d)) {
205        h = (h + 1) & (HASH - 1);
206    }
207
208    return h;
209}
210
211static inline __attribute__((always_inline)) int32_t
212find_aligned_beacon(int32_t a, int32_t overlap, Point v) {
213    for (int32_t l = 0; l < sizes[a]; l++) {
214        if (same(v, points[a][l])) {
215            overlap++;
216            break;
217        }
218    }
219
220    return overlap;
221}
222
223static inline __attribute__((always_inline)) int32_t count_aligned_beacons(
224    int32_t a, int32_t b, Point rotated[BEACONS], Point d, int32_t overlap) {
225    for (int32_t k = 0; k < sizes[b]; k++) {
226        Point v = plus(rotated[k], d);
227        overlap = find_aligned_beacon(a, overlap, v);
228    }
229
230    return overlap;
231}
232
233static inline __attribute__((always_inline)) void
234translate_scanner_points(int32_t b, Point rotated[BEACONS], Point d) {
235    for (int32_t k = 0; k < sizes[b]; k++) {
236        points[b][k] = plus(rotated[k], d);
237    }
238}
239
240static inline __attribute__((always_inline)) int
241vote_scanner_translations(int32_t a, int32_t b, int32_t i, int32_t *j_ref,
242                          Point rotated[BEACONS], int32_t *answer_out) {
243    for ((*j_ref) = 0; (*j_ref) < sizes[b]; (*j_ref)++) {
244        aoc_assert(++work <= WORK, "scanner alignment exceeds 20000000 votes");
245        Point d = sub(points[a][i], rotated[(*j_ref)]);
246        uint32_t h = ((uint32_t)d.x * 73856093u ^ (uint32_t)d.y * 19349663u ^
247                      (uint32_t)d.z * 83492791u) &
248                     (HASH - 1);
249        h = find_translation_slot(d, h);
250        votes[h] = d;
251        if (++counts[h] == 12) {
252            int32_t overlap = 0;
253            overlap = count_aligned_beacons(a, b, rotated, d, overlap);
254            if (overlap >= 12) {
255                translate_scanner_points(b, rotated, d);
256                positions[b] = d;
257                known[b] = 1;
258                {
259                    *answer_out = 1;
260                    return 1;
261                };
262            }
263        }
264    }
265
266    return 0;
267}
268
269static inline __attribute__((always_inline)) int
270match_scanner_rotation(int32_t a, int32_t b, int32_t *i_ref, int32_t *j_ref,
271                       Point rotated[BEACONS], int32_t *answer_out) {
272    for ((*i_ref) = 0; (*i_ref) < sizes[a]; (*i_ref)++) {
273        {
274            int32_t answer;
275            if (vote_scanner_translations(a, b, (*i_ref), j_ref, rotated,
276                                          &answer)) {
277                {
278                    *answer_out = answer;
279                    return 1;
280                };
281            }
282        }
283    }
284
285    return 0;
286}
287
288static int32_t match(int32_t a, int32_t b) {
289    int32_t i = 0, j = 0, shared = 0, na = sizes[a] * (sizes[a] - 1) / 2,
290            nb = sizes[b] * (sizes[b] - 1) / 2;
291    while (i < na && j < nb) {
292        if (distances[a][i] == distances[b][j]) {
293            shared++;
294            i++;
295            j++;
296        } else if (distances[a][i] < distances[b][j]) {
297            i++;
298        } else {
299            j++;
300        }
301    }
302    if (shared < 66) {
303        return 0;
304    }
305    for (int32_t r = 0; r < 24; r++) {
306        Point rotated[BEACONS];
307        i = rotate_scanner_points(b, i, r, rotated);
308        memset(counts, 0, sizeof counts);
309        {
310            int32_t answer;
311            if (match_scanner_rotation(a, b, &i, &j, rotated, &answer)) {
312                return answer;
313            }
314        }
315    }
316    return 0;
317}
318
319static inline __attribute__((always_inline)) int32_t
320align_unknown_scanners(int32_t found, int32_t a) {
321    for (int32_t b = 0; b < ns; b++) {
322        if (!known[b] && match(a, b)) {
323            found++;
324        }
325    }
326
327    return found;
328}
329
330static inline __attribute__((always_inline)) int32_t
331extend_aligned_scanners(int32_t found) {
332    for (int32_t a = 0; a < ns; a++) {
333        if (!known[a]) {
334            continue;
335        }
336        found = align_unknown_scanners(found, a);
337    }
338
339    return found;
340}
341
342static inline __attribute__((always_inline)) int64_t
343compare_scanner_positions(int64_t best, int32_t a) {
344    for (int32_t b = 0; b < a; b++) {
345        Point d = sub(positions[a], positions[b]);
346        int64_t v = (int64_t)abs32(d.x) + abs32(d.y) + abs32(d.z);
347        if (v > best) {
348            best = v;
349        }
350    }
351
352    return best;
353}
354
355static inline __attribute__((always_inline)) int32_t
356collect_scanner_beacons(int32_t n, int32_t i) {
357    for (int32_t j = 0; j < sizes[i]; j++) {
358        all[n++] = points[i][j];
359    }
360
361    return n;
362}
363
364static slice solve(slice s, int32_t part) {
365    parse(s);
366    int32_t found = 1;
367    for (int32_t pass = 0; pass < ns && found < ns; pass++) {
368        int32_t before = found;
369        found = extend_aligned_scanners(found);
370        if (found == before) {
371            break;
372        }
373    }
374    aoc_assert(found == ns,
375               "scanners do not connect through pairwise 12-beacon overlaps");
376    if (part == 2) {
377        int64_t best = 0;
378        for (int32_t a = 0; a < ns; a++) {
379            best = compare_scanner_positions(best, a);
380        }
381        return slice_from_i64(best);
382    }
383    int32_t n = 0;
384    for (int32_t i = 0; i < ns; i++) {
385        n = collect_scanner_beacons(n, i);
386    }
387    qsort(all, (size_t)n, sizeof *all, cmp_point);
388    int32_t unique = 0;
389    for (int32_t i = 0; i < n; i++) {
390        unique += !i || !same(all[i], all[i - 1]);
391    }
392    return slice_from_i64(unique);
393}
394
395slice part1(slice s) {
396    return solve(s, 1);
397}
398
399slice part2(slice s) {
400    return solve(s, 2);
401}
402
403const struct aoc_method aoc_methods[] = {{0, 0}};

aoc.h

1#ifndef AOC_H
2#define AOC_H
3
4#include <stdarg.h>
5#include <stddef.h>
6#include <stdint.h>
7#include <stdlib.h>
8#include <string.h>
9
10/* The only required boundary between infra and a solution.
11 * `input` is read-only and is not owned by the solution.
12 * The returned slice is allocated with malloc. It is the only
13 * block still live when the function returns. Infra copies it
14 * and then frees it.
15 */
16typedef struct {
17    uint8_t *p;
18    size_t l;
19} slice;
20
21/* p is null and l is 0. Infra uses this when a run has no output. */
22static const slice empty_slice = {0};
23
24typedef slice (*aoc_fn)(slice);
25
26/* One named method. The name is a C identifier, at most 31
27 * characters, and it is the URL suffix: /YYYY/D/P/<name>.
28 * estimate and span are examples, not a fixed list. A day
29 * exports as many as it wants. The array ends with {0, 0}.
30 * part1 and part2 are not entries in this list.
31 */
32struct aoc_method {
33    const char *name;
34    aoc_fn fn;
35};
36
37slice part1(slice input);
38slice part2(slice input);
39
40extern const struct aoc_method aoc_methods[];
41
42/* Provided by the runtime. Records msg and returns. */
43void aoc_fail(const char *msg);
44
45/* Stops the run when cond is false and reports msg. */
46_Noreturn void aoc_assert_fail(const char *msg);
47#ifndef aoc_assert
48#define aoc_assert(cond, msg) \
49    do { \
50        if (!(cond)) { \
51            aoc_assert_fail(msg); \
52        } \
53    } while (0)
54#endif
55
56/* Decimal text of a uint64_t is at most 20 digits. A sign and a
57 * little spare fit here. Size a number buffer from this.
58 */
59enum { AOC_I64_TEXT = 32 };
60
61/* Decimal digits of v. No sign. d has room for 20 digits. */
62static inline char *aoc_u64_text(char *d, uint64_t v) {
63    char tmp[AOC_I64_TEXT];
64    char *end = tmp + AOC_I64_TEXT;
65    char *p = end;
66    size_t n;
67    do {
68        *--p = (char)('0' + (v % 10ull));
69        v /= 10ull;
70    } while (v);
71    n = (size_t)(end - p);
72    memcpy(d, p, n);
73    return d + n;
74}
75
76/* Decimal digits of v. The minimum int64_t is not negated. */
77static inline char *aoc_i64_text(char *d, int64_t v) {
78    uint64_t u;
79    if (v < 0) {
80        *d++ = '-';
81        u = (uint64_t)(-(v + 1)) + 1ull;
82    } else {
83        u = (uint64_t)v;
84    }
85    return aoc_u64_text(d, u);
86}
87
88/* n values, one space between them. The author knows the order. */
89static inline char *aoc_u64s(char *d, const uint64_t *v, size_t n) {
90    size_t i;
91    for (i = 0; i < n; i++) {
92        if (i) {
93            *d++ = ' ';
94        }
95        d = aoc_u64_text(d, v[i]);
96    }
97    return d;
98}
99
100static inline char *aoc_i64s(char *d, const int64_t *v, size_t n) {
101    size_t i;
102    for (i = 0; i < n; i++) {
103        if (i) {
104            *d++ = ' ';
105        }
106        d = aoc_i64_text(d, v[i]);
107    }
108    return d;
109}
110
111static inline char *aoc_ints(char *d, const int *v, size_t n) {
112    size_t i;
113    for (i = 0; i < n; i++) {
114        if (i) {
115            *d++ = ' ';
116        }
117        d = aoc_i64_text(d, (int64_t)v[i]);
118    }
119    return d;
120}
121
122/* Write fmt at buf. Return the cursor for the next call.
123 * %d takes int. %i takes int64_t. %u takes uint64_t.
124 * %s takes a C string. %% is a percent sign.
125 * A literal run is memcpy.
126 * %D takes (int *, size_t). %I takes (int64_t *, size_t).
127 * %U takes (uint64_t *, size_t). One space between values.
128 */
129static inline char *aoc_vprintf(const char *fmt, char *buf, va_list ap) {
130    while (*fmt) {
131        const char *lit = fmt;
132        size_t n;
133        while (*fmt && *fmt != '%') {
134            fmt++;
135        }
136        n = (size_t)(fmt - lit);
137        if (n) {
138            memcpy(buf, lit, n);
139            buf += n;
140        }
141        if (*fmt != '%') {
142            break;
143        }
144        fmt++;
145        if (*fmt == '%') {
146            *buf++ = '%';
147            fmt++;
148            continue;
149        }
150        if (*fmt == 's') {
151            const char *s = va_arg(ap, const char *);
152            n = strlen(s);
153            if (n) {
154                memcpy(buf, s, n);
155                buf += n;
156            }
157            fmt++;
158            continue;
159        }
160        if (*fmt == 'd') {
161            buf = aoc_i64_text(buf, (int64_t)va_arg(ap, int));
162            fmt++;
163            continue;
164        }
165        if (*fmt == 'i') {
166            buf = aoc_i64_text(buf, va_arg(ap, int64_t));
167            fmt++;
168            continue;
169        }
170        if (*fmt == 'u') {
171            buf = aoc_u64_text(buf, va_arg(ap, uint64_t));
172            fmt++;
173            continue;
174        }
175        if (*fmt == 'D') {
176            const int *v = va_arg(ap, int *);
177            buf = aoc_ints(buf, v, va_arg(ap, size_t));
178            fmt++;
179            continue;
180        }
181        if (*fmt == 'I') {
182            const int64_t *v = va_arg(ap, int64_t *);
183            buf = aoc_i64s(buf, v, va_arg(ap, size_t));
184            fmt++;
185            continue;
186        }
187        if (*fmt == 'U') {
188            const uint64_t *v = va_arg(ap, uint64_t *);
189            buf = aoc_u64s(buf, v, va_arg(ap, size_t));
190            fmt++;
191            continue;
192        }
193        aoc_assert(0, "bad format");
194    }
195    return buf;
196}
197
198static inline char *aoc_printf(const char *fmt, char *buf, ...) {
199    va_list ap;
200    va_start(ap, buf);
201    buf = aoc_vprintf(fmt, buf, ap);
202    va_end(ap);
203    return buf;
204}
205
206/* Copy n bytes of text into a malloc'd slice. */
207static inline slice slice_from_text(const char *s, size_t n) {
208    uint8_t *p = malloc(n);
209    aoc_assert(p, "out of memory");
210    if (n) {
211        memcpy(p, s, n);
212    }
213    return (slice){p, n};
214}
215
216/* Decimal text of v, allocated at AOC_I64_TEXT. The minimum
217 * int64_t is not negated. slice.l is the bytes written.
218 */
219static inline slice slice_from_i64(int64_t v) {
220    char tmp[AOC_I64_TEXT];
221    char *d;
222    uint8_t *p;
223    size_t n;
224    d = aoc_printf("%i", tmp, v);
225    n = (size_t)(d - tmp);
226    p = malloc(AOC_I64_TEXT);
227    aoc_assert(p, "out of memory");
228    memcpy(p, tmp, n);
229    return (slice){p, n};
230}
231
232/* Parse one decimal slice into *out. A leading '-' is allowed.
233 * Returns 1 on success, 0 for invalid text or int64_t overflow.
234 */
235static inline int slice_to_i64(slice s, int64_t *out) {
236    size_t i = 0;
237    int neg = 0;
238    uint64_t u = 0;
239    if (!s.p || s.l == 0 || !out) {
240        return 0;
241    }
242    if (s.p[0] == '-') {
243        neg = 1;
244        i = 1;
245        if (s.l == 1) {
246            return 0;
247        }
248    }
249    for (; i < s.l; i++) {
250        uint8_t c = s.p[i];
251        if (c < '0' || c > '9') {
252            return 0;
253        }
254        uint64_t digit = (uint64_t)(c - '0');
255        uint64_t limit = (uint64_t)INT64_MAX + (uint64_t)neg;
256        if (u > (limit - digit) / 10u) {
257            return 0;
258        }
259        u = u * 10u + digit;
260    }
261    if (neg) {
262        *out = u == (uint64_t)INT64_MAX + 1u ? INT64_MIN : -(int64_t)u;
263    } else {
264        *out = (int64_t)u;
265    }
266    return 1;
267}
268
269#endif

The aha moment

The scanners know where the beacons are, but only in their own private coordinate systems. Wonderful. We have 28 reports, each containing 25 to 27 beacons, with coordinates from -984 to 962. There are only 725 observations altogether. The difficulty is deciding which observations describe the same thing.

Trying to assign twelve beacons to twelve other beacons would be a miserable start. Before searching correspondences, read the restriction on orientation: scanners rotate through right angles. There are six choices for the direction they face and four choices for which way is up, giving 24 rotations. Arbitrary permutations and signs produce 48 transformations; half are reflections, which a physical rotation cannot perform.

Now fix one rotation R and tentatively match beacon b from the unknown scanner to beacon a from a known scanner. That single guess determines the entire translation: t = a - R(b). Every other genuine match must produce exactly the same t. Aha! We can let pairs vote for translations instead of constructing sets of twelve correspondences. Twelve votes identify a candidate alignment, which we confirm by transforming the report and counting exact shared positions.

This is already affordable. Trying every unordered scanner pair, every rotation, and every beacon pair in the local input would produce about 6.08 million votes. There is no need to search the enormous surrounding ocean. The observations themselves supply all candidate translations.

We can make the expensive work rarer still. Rotation and translation preserve the squared distance between two beacons. Twelve shared beacons contribute 12 × 11 / 2 = 66 shared pair distances. Build a sorted distance list for each report, retaining repeated distances: equal lengths can belong to different beacon pairs. If two lists share fewer than 66 entries, those scanners cannot overlap sufficiently. Here just 41 of the 378 scanner pairs survive. Passing this filter is a reason to investigate, not proof of an alignment; unrelated configurations can share distances.

Choose scanner zero as the origin and begin extending the known map. When a report aligns with any known scanner, transform its beacons into scanner zero's frame. That newly known report can unlock another one. A failed match against scanner zero is therefore not a failed scanner. The local reconstruction takes three passes through the reports, accepts 27 alignments, and casts 228,166 translation votes. Once every report uses the same frame, sorting and deduplicating the observations leaves the beacon count.

Part two asks for the largest Manhattan distance between scanners. After all that geometry, this is a welcome breather. We have already found each scanner's position: its local origin becomes R(0) + t = t. Keep that translation when accepting an alignment, then compare the 378 scanner pairs using |dx| + |dy| + |dz|. There is no second reconstruction. Even the arbitrary choice of scanner zero is harmless: a common translation, axis permutation, or sign reversal preserves these distances.

The implementation accepts at most 64 scanners with 64 distinct beacons each, local coordinate magnitudes through one million, and aligned coordinate magnitudes through 100 million. Alignment stops after 20 million translation votes. It also requires every scanner to connect to scanner zero through pairwise overlaps of at least twelve beacons, as described by the story; a stalled reconstruction is refused. The useful habit here is to separate a cheap invariant that rules possibilities out from an exact check that lets us commit to one.

See also

Categories for 2015–2024 adapted from u/Boojum’s 500 Stars: A Categorization and Mega-Guide ↗. A day can belong to several categories. Tags from 2025 onward are our additions.

Try your input

One POST, one reply. Your input is not saved.