In C

View Solution

Show canned hints
KeywordsContent
start

The goal of this puzzle is to assemble a working C program from the given 53 lines of code. The first thing you need to do is to identify the external resource that gives the correct ordering of the lines. The nature of that resource will indicate what you need to do after that.

correspond, note, piece

The correspondence between "In C" and the program is based on the pitches of the notes. The lengths of the notes are not relevant. Tied notes and consecutive rests count as one. Some elements of the code (for example, parentheses) are not reflected in the correspondence.

order, program, compile

In "In C", the segments are played in order, but each may be skipped or repeated any number of times at the performer's discretion. Similarly, in this puzzle you must omit some lines and repeat others to form the final C program. There's no pattern or external correspondence; you just have to work through it step by step. You can assume most lines are used, unless they are invalid, and that lines generally progress the goal of filling in the array; the program doesn't have room to waste on executing useless or redundant instructions.

line, repeat, skip

[I don't know how to write a canned hint for this part. Just give them something based on their request and the listing in the solution. Err on the side of giving them more help. You can also use the last part of the previous canned hint if they don't know it already:]

You can assume most lines are used, unless they are invalid, and that lines generally progress the goal of filling in the array; the program doesn't have room to waste on executing useless or redundant instructions.

extract

The program sets values in the array F as it runs. There are 22 entries (and one sentinel at F[22]). Lines 49-53 are the final loop, which goes through F and modifies all the values to ones amenable to extraction. The comment on line 46 gives a pattern for the extraction. If you did it right, the final values in F should all be close to integers, and there should be a natural way to read them. If some of the values look invalid, though, then you may need to think a bit more about what that way is.
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>

/* (c) 1964
- This has been tested with clang and gcc. Make sure to compile with `-lm`.
- Undefined behavior is not allowed. Other compiler warnings are okay to ignore.
- All array entries except the final sentinel are to be set to a nonzero value.
- Counting comments as one, there are ten types of thing in this puzzle.
*/

int main() {
    , ++P
    typedef
    typedef
    (!&N); continue; }
    *P /* The value set here is a float that might not look exact, but will still pretty clearly give the letter S in the end. */
    *P = 10 +
    *P = 10 +
    +raise(9)
    +rand())[&F]);
    +rand())[&F]);
    -0; *P /=
    -0; *P /=
    /* At this time, 5 out of 22 array entries should be set to their final values. */ *F;
    while (*(++P));
    '}' - '{'; *(P
    ((isxdigit(*F) * /* The final program should not end up showing nondeterministic behavior. */
    *(P += 4); /* At this time, P should point to the last meaningful array entry. */
    *F - *P / 30);
    + '\x13') = (N = ' ',
    -0.795 * *F + sqrt(
    0[&Y]; } while
    I; *(F - ~(int) (
    % 69; *P /= fabs((float)
    /* The first array entry is used as scratch space, and so is one of the only entries that will be modified more than once. */ N = 41}; F[
    /* This entry, around the middle of the array, is being set to its final value. */ N -= 32] = *F;
    = *F * log10((int) trunc(
    = 9. / N; P -= (int)
    F[3] = *F; /* The value set here will, after the end of the program, be read as the letter E. */
    float F[23] = {Y =
    long time(); 0xe5cap3 void
    ~(int) asinh(*P); ++P;
    /* The code up to here has run pretty normally, */ float T; T /* but this will soon no longer be true. */
    (*(F + 16) = *(F + lround(*F - tan(
    -8, *P = (abs(*P) << abs(*P))
    -8, *P = (abs(*P) << abs(*P))
    0[&N]; if(&Y) do { *P -=
    Y)); N--; Z = ~-(--P - F) + N *
    Y)); N--; Z = ~-(--P - F) + N *
    free() volatile sin(); restrict exit() /* Uh-oh. */
    int N; float Y; complex Z;
    lround(*P)) + 3 ** P - !exit * (long) (
    58)))) / *F + 13)) = *P * tan(208); *F =
    log(*P)); *(P + 4) = *P + /* The value set here will, after the end of the program, be read as the letter N. */ *F -
    ); F[--N] = *(P - &Y + &N) / *F + *(P + 0xf); exit;
    )[N] = F[-~N]; Y = F[N--] = *F * 0x1.a895dp0; (exit
    , F[--N] = *F + 0x1.b1aep21 / (0xdead + 0xbeef + 0xcafe + 0xf00d)), exit
    , F[--N] = ++N + N-- / (++P - P--) + *P - 0x.accp4, exit
    18[F] = 1[F] = P[~-N] - (N ^ 12); Y
    ; F[--N] = *F = 0x.9b3p5; exit - exit + exit - exit + exit,
    Z += N-- - (F - --P); *(F + N) = Z++ / ~-N; N++; (P
    Z -= N++; errno[P++] = *(F + -~N); *P = --Z / ~-N; (P++[N] = (
    ) = *(F + 'b' - Y * '5') /* Parse the extraction as follows: */ = *F /* ???? ?? ???? ? ?????? ???? ? (N), */ = *F /* using the current value of N at this time. */ = *F = *F + '\0'; P -= '\x4';
    -81 + (*F + sin(*F - cos(*F - tan(*F - fabs(*F))))); /* This line sets two array entries to their final values, */ if(*P == 0x0) *P = fabs((0x.29c2p0 * *F) * Z) - *F; --P; /* for a total of 18 out of 22. */ Z *= .638424 *
}