8
\$\begingroup\$

Consider the 74 characters from the 2016 time capsule string (note the leading space):

 !!!!!#$$%&())))*+...1449:=@@@AHILOQQQTTZ\\^`````````eefmpxy{||||~~~~~~~~~

Your task is to write as many programs as possible (in the same language) using these characters. The output of each program must be nonempty. When all of the programs and their outputs are considered, it must only use each of the 74 above characters no more than once.

Your score is determined by the number of programs you have written, with the total length of the programs being a tie-breaker (greatest length wins).

Some more rules:

  1. Each program must terminate.
  2. Each program must be a full program and output in a reasonable format.
  3. All output to STDERR is ignored.
  4. You may not run your program with any flags, except those required to run the program. (E.g., a -e flag that executes program source.)
  5. If the program has output that cannot be suppressed, you may ignore when considering the output. (E.g., you may ignore trailing newlines.)
  6. Each program should be able to be executed with empty stdin.

Example

If I had programs 4 and T1~ that outputted 4 and 9 respectively, they would, when considered together, be:

44T1~9

Which can be seen to be a subset of the capsule string. However, if I had programs 4@|4 and |e+ that outputted 4 and f respectively, they would be:

4@|44|e+f

And, since there are 3 4s, it is not a subset.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Can be disregard ans = .. in the output from MATLAB? That's allowed by default, except for challenges like "Hello, world" and other challenges with a very strict format. \$\endgroup\$ Mar 28, 2017 at 11:18
  • 1
    \$\begingroup\$ Programs are not expected to produce different outputs, or be different themselves, are they? \$\endgroup\$
    – Fatalize
    Mar 28, 2017 at 11:26
  • \$\begingroup\$ @StewieGriffin Yes, you can, I'll edit to reflect this. \$\endgroup\$ Mar 28, 2017 at 15:06
  • \$\begingroup\$ @LuisMendo Each program should be able to be executed with empty stdin. \$\endgroup\$ Mar 28, 2017 at 15:08
  • \$\begingroup\$ @SparklePony I wouldn't quite say "absurd". \$\endgroup\$ Mar 28, 2017 at 15:43

5 Answers 5

5
\$\begingroup\$

Japt, 11 13 programs, length 61

\x:#).&~L // outputs 9  (41 & ~100)
~T+~Tf)p  // outputs 4  ((~0 + ~floor(0)) ** 2)
$~Q$ *\~Z // outputs 1  (~'"' * ~0)
I%A^O||@{=!(Hmy))  // outputs 4  (64 % 10 ^ {} || function(X,Y,Z) { return function() { return ((U = !(H.m("y")))) } })
`!        // outputs !
`!        // outputs !
`.        // outputs .
`@        // outputs @
`Q        // outputs Q
`e        // outputs e
`|        // outputs |
`~        // outputs ~
`~        // outputs ~

It's awfully hard to come up with an answer that isn't just a string literal and outputs something other than a number...

Output and programs combined:

 !!!!!#$$%&())))*+...1449:=@@@AHILOQQQTTZ\\^`````````eefmpxy{||||~~~~~~~~~

I think I got 'em all...


When stripped down to the bare minimum:

#)&~L
~T+~T)p
~Q*~Z
I%A
`!
`!
`.
`@
`Q
`e
`|
`~
`~

It leaves these chars for future programs/outputs:

 !$$()).:=@HO\\^fmxy{||

You can trade two of $, ), or | for two of any of the chars in the nine string literals; that is, two of any of !.@Qe|~.

Additionally, you can trade out the Q in the third program for H or O, and the Z for H, O, @, or {.

\$\endgroup\$
2
\$\begingroup\$

PHP, 22 programs

Yeah, I get it's kind of boring.

Programs (separated by single newline):

!
!
$
)
)
.
4
@
Q
T
\
`
`
`
`
e
|
|
~
~
~
~

Output and programs combined:

!!!!$$))))..44@@QQTT\\````````ee||||~~~~~~~~
\$\endgroup\$
5
  • \$\begingroup\$ You could add Carrot to the list (but `` outputs nothing) \$\endgroup\$
    – user41805
    Mar 28, 2017 at 11:05
  • \$\begingroup\$ And so does $ (this gets user input). So in all, in Carrot, you have 2 less programs (remove the one for $ and \) \$\endgroup\$
    – user41805
    Mar 28, 2017 at 11:12
  • \$\begingroup\$ @Kritixi Lithos Does it support 🥕? \$\endgroup\$ Mar 28, 2017 at 11:20
  • \$\begingroup\$ @RobertFraser All I can see is a square. But sure, it outputs it if it is the code. You can try it here \$\endgroup\$
    – user41805
    Mar 28, 2017 at 11:28
  • \$\begingroup\$ @KritixiLithos That's a carrot emoji: emojipedia.org/emoji/%F0%9F%A5%95 \$\endgroup\$
    – Okx
    Mar 28, 2017 at 15:20
1
\$\begingroup\$

PowerShell, 2 programs, length 31

+!!($eefmpxy =9)

Try it online!

Outputs 1.
Works by setting the variable $eefmpxy to 9, encapsulating that in parens, taking the Boolean-not ! of that (which turns it to $False), then the Boolean-not of that (which turns it to $True), then casts as an integer with +, turning it to 1. That's left on the pipeline and output is implicit.


4*!$AHILOQQQTTZ

Try it online!

Outputs 4.
Works by initializing the variable $AHILOQQQTTZ to the default of $null, the Boolean-not ! of which is $True. That's implicitly cast to an integer 1 due to the multiplication of 4*, so the result of 4 is left on the pipeline and output is implicit.


We're really limited in PowerShell for other things, as though we have plenty of pipe characters | to pipeline commands together, we only have one { and no }; too many ) for the lone (; the backtick ` is used as a "line continuation marker" to interpret multiple lines as one (used for readability), but we have no linefeed to go with it; and the ~ and ^ characters are "Reserved for future use" and thus toss a syntax error when you try to use them. So, most of the characters are useless, which is a shame.

While the # character starts a comment (and everything after it is completely ignored), it feels cheaty to use it that way, so I didn't include it above.

\$\endgroup\$
0
\$\begingroup\$

Cardinal, 1 program, length 73

%#~~~~~~~~~!!!!!+=.*449eefmpxyAHLOQQQTTZ`````````@@@$$I\\^{|||| ())))&..:

Outputs 1

Try it online!

Cardinal can only have 1 valid program that will do anything as there is only 1 %.

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 4 programs, length 19

Programs

)O!            # outputs 1    fac(sum([]))
A`\            # outputs y    2nd_last(alphabet)
THf`x          # outputs 4    last_primefactor(int(10,16))*2
TL`\           # outputs 9    2nd_last(range[1 ... 10])

Output and programs combined

!)149AHLOTT\\```fxy
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.