Prelude
[Back]
Mid-January is the quietest time of the year at the North Pole. The frantic Christmas rush is over, along with the unusual phenomena that, somehow, come with it every year. This makes it all the more surprising when a multiversal rift forms and you, along with many of Santa's elves, find yourself on ... a long-abandonded college campus?
After examining the situation, you determine that you can reverse the effect of the rift to escape, but it will take a lot of energy; 9 stars of energy, to be precise. It seems like the narrative structure of the universe you're in gives you 1 star every time you solve a problem, but apparently you can't even see a problem until you've solved all of those "before" it.
As you try to figure out how you're ever going to solve any problems at all, you notice a piece of paper on the ground, and pick it up. It says "Noulith" and "x is input, y is output" at the top, and contains the following... lines of code?
! (iota 0) find (\i -> (enumerate z) all (\[
$ map int; y := only ! x.
'W': V(0, -1), 'E': V(0, 1)}; s :=
(** >>> (map (fold gcd))
(g).int;
(sort (
) filter (
)) then transpose
- on len
-) >>> abs >>> (^ 2));
.words map int; for (_ <- 0
// 2 + c; h := \n ->
0); for (
1)^0.5 - 1) // 2; g := \n,
2) .* (1 - z % 2)).set); y := len(s);
99 <);
:1}; p := V(0,
== c); y := f('e') map (.. (f('c').only))
>>> set
[:-1].reverse with
[i[:-1] map (!! 0), i[-1]])
[p] += 1); y := max(
\i -> z[i[0]])
\z -> (3 * z + 1) .+ (z //
^ 2) on int);
c -> n * (n + 1)
d := {'N': V(-1, 0), 'S': V(1, 0),
dict; y := (lines ((
f := \w -> (prefixes w)
flat_map transpose sum ((fold
flat_map transpose then
g := sum >>> (2 ^); y := x.lines.reverse.
i <- x) (p += d[i]; s
in)).enumerate.sum
int;
j -> x[j[0]][j[1]]
j, k] -> h((i g z[1]) * j) == k));
join '' then
map lines map (\i ->
map(([0, float('-inf')] !!) on ('#'
n - g(f(n), 0); y := (_ g z[1])
s := set ! lines(x)[0]
then transpose map
til int(lines(x)[1] search '\\d+')) (s ||= s.flat_map(
til len(x[0])); f := \c -> i filter (\
values s);
words map f fold
x .= lines; i := (0 til len(x)) ** (0
x split '\n\n')[-1])) map (
x) sum ((
y := (words
z := (words x) map int; f := \n -> ((8 * n +
z := (x split '\n\n')[:-1]
zip (suffixes w)
{:0, V(0, 0)
You have a feeling that this code would solve all your problems, somehow, even though it seems to be disordered. Indeed, you think that all you'll need from each problem is the code to solve it and the answer the code gives you, with things such as where exactly you are and the description of the problem itself being otherwise irrelevant. Your overall plan is thus clear: use the code to solve the problems and get enough stars to escape this f**king place.