 Location: Coral Reef
Depth: 111

# Solution to Pipe

### by Brian Chen

Summary: The puzzle transforms input given to it in 7 stages.

• Stage 1 reads a sequence of digits and uppercase letters, transforming each one individually into a number between 0 and 35 inclusive, via base 36 (so digits stay as they are, A becomes 10, B becomes 11, …, Z becomes 35). It fails if any character is not a digit or uppercase letter.
• Stage 2 checks if each number from stage 1 is a prime, and fails if not; it outputs the product of all its input.
• Stage 3 converts the result of Stage 2 into its corresponding chemical element name; it requires each number to be less than or equal to 118 and fails if that is not true.
• Stage 4 pairs up adjacent letters of the element from Stage 3, converts them to numbers by A=1, B=2, …, and multiplies the numbers in each pair together. It fails if the element name has an odd number of letters.
• Stage 5 calculates 8 − floor(tan(x)) for each x from stage 4; it requires the result to be positive or zero, and fails if the result is ever negative.
• Stage 6 prepends the digit 1 to the decimal representation of each number from stage 5, checks if each resulting number is a prime, and fails if not.
• Stage 7 multiplies the primes from stage 6 together, converts it to a base 36 number using 0~9 and A~Z as digits, and requires all digits in the result to be letters (A~Z), failing if the result has any digits in the range 0~9.

Solvers must deduce these rules; find the only input that gets through all 7 stages successfully, viz. "33"; and apply the transformations to 33 itself to get the answer, DARN.

A detailed solution/walkthrough follows. (Note that intermediate "ok" messages from the output are elided for brevity.)

Type stuff into the box.

> hello
Error in stage 1: unexpected 'h', expecting only digits and uppercase letters
> ???
Error in stage 1: unexpected '?', expecting only digits and uppercase letters

Digit or uppercase letter? Let's try it.

> 0
Error in stage 2: 0 is not prime
> 1
Error in stage 2: 1 is not prime
> 2
Error in stage 6: 110, at position 1 of 3, is not prime
> 3
Error in stage 4: unpaired last letter 'm'
> 4
Error in stage 2: 4 is not prime
> 5
Error in stage 4: unpaired last letter 'n'
> 6
Error in stage 2: 6 is not prime
> 7
Error in stage 6: 18, at position 1 of 4, is not prime
> 8
Error in stage 2: 8 is not prime
> 9
Error in stage 2: 9 is not prime

Well, at least a single digit gets through to stage 2, and causes an error if it's not prime.

Unfortunately, multiple-digit numbers don't; if you enter "10", Stage 2 only complains about the number 1. Weird.

> 10
Error in stage 2: 1 is not prime

> A
Error in stage 2: 10 is not prime
> B
Error in stage 6: 110, at position 1 of 3, is not prime
> C
Error in stage 2: 12 is not prime
> D
Error in stage 6: 18, at position 3 of 4, is not prime
> E
Error in stage 2: 14 is not prime
> F
Error in stage 2: 15 is not prime
> G
Error in stage 2: 16 is not prime

At least from the letters that cause an "Error in stage 2", it appears that A becomes 10, B becomes 11 and so on. They don't overlap with the digits at all; it makes sense. In fact, these are the standard base-36 digits, which will be helpful for verification at the end.

Why do the numbers have to be prime? Can we input more than one letter or number?

> 00
Error in stage 2: 0 is not prime
> AA
Error in stage 2: 10 is not prime

Yeah, at least it got through to stage 2. Let's try a letter we know is a prime.

> BB
Error in stage 3: number 121 out of range

Out of range? That sucks. But at least we now are pretty sure that stage 2 multiplies the primes together, since B = 11. Now we can try getting different numbers past stage 2, as long as their prime factors are all at most 35. What about 120 or 119?

> 22235
Error in stage 3: number 120 out of range
> 7H
Error in stage 3: number 119 out of range

We can't express 118 because it has 59 as a prime factor, but 117:

> 33D
Error in stage 4: unpaired last letter 'm'

gets through. Interesting. (Obviously, we just happened to start at 121, right next to the upper bound, but the knowledge that it's a range should allow the solver to find the bound through binary search quickly.)

With more experimentation, one can figure out that the numbers you can get through stage 2 that are below 117 all get through stage 3 as well. This, combined with some inspiration from a source such as looking up 117 on Wikipedia and seeing ununseptium or having one's local Course 5 major available, makes it reasonable to guess that these numbers are being used as atomic numbers of elements. (It is also evidently possible to backsolve this step after guessing stage 4 and thinking that 29 corresponds to a word ??PP??.)

Continuing the tests:

> 3
Error in stage 4: unpaired last letter 'm'

One can verify that the last letter of element 3, lithium, is indeed 'm'. The error also says something about "unpaired letters"...

This message, when coupled with more experimenting, should allow one to discover that the elements that get through stage 4 are those with even-length names. So letters are paired up and something is done with them. What could it be?

Getting further probably requires you to test all the atomic numbers that are achievable. You should eventually find:

29, copper

> T
Error in stage 5: 8 - floor(tan(256)), at position 2 of 3, is negative

30, zinc

> 235
Error in stage 5: 8 - floor(tan(234)), at position 1 of 2, is negative

42, molybdenum

> 237
Error in stage 5: 8 - floor(tan(300)), at position 2 of 5, is negative

91, protactinium

> 7D
Error in stage 5: 8 - floor(tan(300)), at position 2 of 6, is negative

> 25B
Error in stage 5: 8 - floor(tan(234)), at position 2 of 6, is negative

This stage is quite hard because these are the only five stage 5 error messages you can get. But you can guess that 8 is a magic number and that the magic formula is f(x) = 8 − floor(tan(x)).

If you make the correct leap that adjacent letters in the chemical name are paired, then the position will tell you the relevant letter pair, which improves the information you have considerably.

29: co[pp]er
30: [zi]nc
42: mo[ly]bdenum
91: pr[ot]actinium

If you are a crazy-dedicated puzzlehunter who has memorized the A=1, B=2 correspondence, you will quickly be able to notice:

29: (P = 16) × (P = 16) = 256
30: (Z = 26) × (I = 9) = 234
42: (L = 12) × (Y = 25) = 300
91: (O = 15) × (T = 20) = 300
110: (R = 18) × (M = 13) = 234

The fact that there are two pairs of equal products from different letters among these is entirely an evil coincidence.

Okay! The hard part of the puzzle should be over. There are plenty of stage 6 failures to look at, and applying the magic formula from stage 5 should make the pattern easy to spot.

2: [he][li][um]

> 2
Error in stage 6: 110, at position 1 of 3, is not prime

[he] = 8 × 5 = 40; 8 − floor(tan(40)) = 10

7: [ni][tr][og][en]

> 7
Error in stage 6: 18, at position 1 of 4, is not prime

[ni] = 14 × 9 = 126; 8 − floor(tan(126)) = 8

So 10 becomes 110 and 8 becomes 18. It seems that stage 6 is prepending the digit 1 to the result of each pair, and requires the result of prepending 1 to always be a prime. So we get another a list of primes? This should remind you of stage 2 and lead you to guess that the resulting primes are multiplied together.

What's the last step?

6: [ca][rb][on]

> 23
Error in stage 7: unexpected '3' in base-36 representation

We're guessing that the input is a bunch of primes, which will probably get multiplied together, and the output is base-36. Let's check our "primes get multiplied together" hypothesis.

6: [ca][rb][on]
[ca] = 3 × 1 = 3; 8 − floor(tan(3)) = 9
[rb] = 18 × 2 = 36; 8 − floor(tan(36)) = 1
[on] = 15 × 14 = 210; 8 − floor(tan(210)) = 9

19 × 11 × 19 = 3971

3971 in base 36: 32B. (Stage 1 should make the solver confident that numbers and letters are to be used for base 36.)

Other inputs that can be used to verify this hypothesis:

> 25
Error in stage 7: unexpected '8' in base-36 representation
> 2D
Error in stage 7: unexpected '1' in base-36 representation
> 2T
Error in stage 7: unexpected '5' in base-36 representation

Looks good! Now let's figure out the answer! You should have stumbled upon the "Success!" message very early while experimenting, but you have to figure out what every stage does to be able to extract the answer from it:

> 33