28
\$\begingroup\$

Using the 74 characters from the 2016 time capsule string

H@~*^)$.`~+1A|Q)p~`\Z!IQ~e:O.~@``#|9@)Tf\eT`=(!``|`~!y!`) Q~$x.4|m4~~&!L{%

write N code snippets all in the same language where:

  • The 1st snippet outputs 1.
  • The 2nd snippet outputs 2.
  • The 3rd snippet outputs 3.
  • ... etc. ...
  • The Nth snippet outputs N (the number, not the literal letter).

A "code snippet" is defined as any of these:

  • A full program with no required input that outputs the number normally.
  • A function with no required arguments that outputs/returns the number normally.
  • A REPL expression that evaluates to the number.

(You may mix and match these three variants in your N snippets.)

The characters you're allowed to use in the combined set of N snippets are precisely the 74 characters of the time capsule, plus floor(N/2) extra "wildcard" bytes that you may use anywhere.

For example, the time capsule contains three @'s so in the entirety of your N snippets there may only be up to three @'s present unless you decide to use some of your floor(N/2) wildcard bytes for additional @'s.

Thus, not counting wildcards, the combined set of characters in your N snippets must be a subset of the 74 time capsule characters. Their combined lengths cannot exceed 74. You may not reuse time capsule characters or wildcard bytes between snippets.

Notes

  • The are no other limits on snippet length or how many wildcards may be used per snippet.

  • You must write all snippets for 1 through N. It's not 0 to N-1, not k to N+k-1.

  • The snippets must be individual, not one snippet that outputs the list 1, 2, 3, ..., N.

  • Outputs may be floats like 3.0 in place of 3 and you can use a base other than decimal if it is your language's natural base. You must use the same base for all snippets.

  • The wildcards are counted as bytes in your language's encoding. This will probably be ASCII but e.g. if counts as one byte in your encoding then you can use it as a single wildcard byte.

  • You may use wildcard bytes for multibyte characters. e.g. is normally three bytes so you could use it in a snippet but it will cost three of your floor(N/2) wildcard bytes.

  • Newlines such as \r\n may be considered one byte.

Example

In Python, N = 4 is possible just using the REPL. There are floor(4/2) = 2 wildcards.

  1. 1 from the time capsule is an expression that evals to 1.

  2. 2 consists of a single wildcard, namely the 2. Evals to 2.

  3. 3 also consists of a single wildcard. Evals to 3. No more wildcards.

  4. 4 is luckily in the time capsule and it evals to 4.

These snippets are short and trivial. A real answer would likely be much more complex.

(Five and beyond in Python may certainly be possible but I'll leave it to the professionals.)

Scoring

The answer with the highest N wins; i.e. the one that climbs the integer ladder the highest.

In case of a tie, the answer that used the fewest wildcard bytes wins.
In case there is still a tie, the answer that used the fewest cumulative characters wins.
If there is still a tie, the earlier answer wins.

\$\endgroup\$
  • 1
    \$\begingroup\$ If a programming language doesn't have a REPL, can we still submit an expression in that language if it evaluates to the appropriate value? (For example, is 4 a valid snippet that returns 4, in older versions of Perl which have no REPL?) \$\endgroup\$ – user62131 Jan 4 '17 at 9:33
  • 1
    \$\begingroup\$ Oh, and another question: in a language with a non-ASCII-compatible encoding, do we treat the time capsule characters as characters (translating them to the language's encoding), or as bytes (writing a program such that viewing the program as ASCII would appear to be contained entirely of time capsule characters)? In some languages with weird character sets, most of the time capsule characters aren't even in the character set, which makes them hard to use as-is. \$\endgroup\$ – user62131 Jan 4 '17 at 9:36
  • 1
    \$\begingroup\$ What about leading zeroes? Is 07 the same as 7? \$\endgroup\$ – Emigna Jan 4 '17 at 13:32
  • 1
    \$\begingroup\$ It is really bugging me that the string contains neither - nor n... \$\endgroup\$ – devRicher Jan 4 '17 at 14:22
  • 1
    \$\begingroup\$ Can "snippets" in stack-based languages leave their values on the stack? \$\endgroup\$ – FlipTack Jan 4 '17 at 17:23

11 Answers 11

10
\$\begingroup\$

CJam, 25 snippets, 12 wildcards, 64 bytes

1
Q!)
Z
4
5
6
L``(*$)#
8
9
T!T
B
C
D
E
F
G
H
I
J
K
O`e`~~!!
B`:)
Q``$e`~~@~@=~+
Q!)4
Amf

Try it online!

Wildcards:

568BBCDEFGJK

I feel that I have to post quickly, before Dennis outgolfing me.

\$\endgroup\$
9
\$\begingroup\$

CJam, 23 snippets, 11 wildcards, 45 bytes

Q!
Q!)
Z
4
4)
6
7
8
9
A
B
C
D
E
F
G
H
I
J
QT|T+e`
O!)1
L!`e`(:)
6mf

Try it online! | wildcard counter (ignore the newlines)

\$\endgroup\$
5
\$\begingroup\$

JavaScript, 10 numbers, 5 wildcards

Remaining characters: !!#$$%&())))*...:=@@@HILOQQQTTZ\^```eefmpy{|||~~~~~~~~~

5/5 bonus characters used: 37680

Programs:

  1. 1
  2. !``+!``
  3. 3
  4. 4
  5. 4|!``
  6. 6
  7. 7
  8. 8
  9. 9
  10. 0xA

I had hoped one of the strings I could make using \xAB would be a number, but unfortunately none of the combinations I tried would yield any. The ^ (XOR) character would also be interesting to use, but I currently don't see any opportunities where it can be used to make a great enough number.

If you see another feasible combination, let me know in the comments.

Edit: Added #10 thanks to Arnauld

\$\endgroup\$
  • 1
    \$\begingroup\$ I think you can add 10. 0xA (with 0 being a new wildcard granted for reaching 10) \$\endgroup\$ – Arnauld Jan 4 '17 at 17:18
  • \$\begingroup\$ You can do (Q=!``)|Q for 1 to get an extra 1 somewhere. Not sure if that'll help though \$\endgroup\$ – ETHproductions Jan 4 '17 at 18:39
4
\$\begingroup\$

Pyth, 12 snippets, 20 bytes (6 wildcards)

f@

Find the first number where root(n,n) is truthy, starting from 1. Output: 1

y!H

Double not {}. Output: 2

3

Wildcard #1. Output: 3

4

Output: 4.

5

Wildcard #2. Output: 5

6

Wildcard #3. Output: 6

7

Wildcard #4. Output: 7

8

Wildcard #5. Output: 8

9

Output: 9

T

Preinitialized variable. Output: 10

+T!Z

Ten plus not zero. Output: 11

12

Wildcard #6 (2). Output: 12

\$\endgroup\$
4
\$\begingroup\$

Octave, 6 numbers, 3 wildcards

1: ~~I          % not(not(sqrt(-1))) evaluates to true (or 1)
2: 2            % Wildcard
3: 3            % Wildcard
4: 4
5: (T=4)+~~T    % Create a variable T=4, then add not(not(T)) which evaluates to 1.
6: 6            % Wildcard

I still have 1, 9 and * left, but I don't know if it will help me much. I'll see what I can do with those :)

Not easy getting many numbers when not using an Esolang. I'm hoping I'll be able to get one or two more, but I think it'll be hard.

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

Pushy, 10 numbers (4 wildcards)

All of these are snippets which leave the result on the stack. You can test this in the online interpreter by appending # to each snippet (to print the number)

A(      \ 1:  Get alphabet and check that 'Z' >= 'Y'. Results in 1 (True)
x&+     \ 2:  Check stack equality (True - both are empty) then duplicate and sum.
3       \ 3:  Push 3 (1 wildcard)
4       \ 4:  Push 4
1 4+    \ 5:  1 + 4 in postfix, leaves 5 on the stack (1 wildcard)
`L`T%   \ 6:  Get character code of 'L' and modulo by T (ten) - leaves 6 on the stack
7       \ 7:  Push 7 (1 wildcard)
8       \ 8:  Push 8 (1 wildcard)
9       \ 9:  Push 9
T       \ 10: Push 10

This answer is not yet complete - although it seems unlikely I will get much further.

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 12 numbers, 6 wildcards

 1:    1                                   -> 1
 2:    )O!x                                -> sum([])!*2
 3:    4L`\                                -> 2nd_last(range(1...4))
 4:    4                                   -> 4
 5:    5        # wildcard 1 = 5           -> 5
 6:    6        # wildcard 2 = 6           -> 6
 7:    Tf`~                                -> or(last2(prime_factors(10)))
 8:    8        # wildcard 3 = 8           -> 8
 9:    9                                   -> 9
10:    T                                   -> 10
11:    A`Q!T+   # wildcard 4 = T           -> (y==z)!+10
12:    TÌ       # wildcard 5,6 = T,Ì       -> 10+2
\$\endgroup\$
1
\$\begingroup\$

Hexagony, 6 numbers, 3 wildcards, 23 bytes

1!@
))!@
)|\@$!
4!%
4)!:
6!@

Try it online!

The entire sixth program is made from wildcards.

The only really interesting one is 3. While I could do that as 4(!@, that would leave me without a 4 to generate 5 easily, so I went with this instead:

 ) |
\ @ $
 ! .

Due to the |, the ) on the first line is run twice, before the IP wraps to right-hand corner. $ skips over the @, and then the \ redirects the IP through the ) a third time. The IP wraps to the bottom left corner, ! prints the 3 and @ terminates the program.

I don't think more than 6 snippets are possible, because there are only 5 printing commands (!!!!!) and 5 commands that can be used to terminate the program (@@@%:). So after the fifth snippet, we need at least two wildcards per snippet. Hence, even if I managed to get 6 without using a wildcard for it, there wouldn't be enough wildcards left to go to snippet seven.

\$\endgroup\$
1
\$\begingroup\$

JavaScript, 8 numbers, 4 wildcards

 1: 1
 2: -~!``
 3: 4+~!$
 4: ~!``*~!``
 5: 4|!$
 6: 0xf^9
 7: 7
 8: 8

I might try again later - I'm kind of wasting characters on 2 and 6, when you get down to it.

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

Befunge-98, 4 snippets, 18 bytes, 2 wildcards

!.@
!:+.@
41-.@    wildcard 1 = -
4.#A9H   wildcard 2 = .

Characters left: !!!$$%&())))*=ILOQQQTTZ\^`````````eefmpxy{||||~~~~~~~~~

I doubt more are possible, since every extra program will require a form of output, and all ., are already used up. If I can figure out a way to make 3 and 5 without a wildcard, then it's possible.

The last program will eventually terminate due to the stack filling up. A and H with no fingerprints loaded will reflect, and the program will keep pushing 9's.

\$\endgroup\$
  • \$\begingroup\$ I don't think the last one is valid. Unless the challenge says otherwise, programs need to terminate. \$\endgroup\$ – Martin Ender Jan 4 '17 at 22:26
  • \$\begingroup\$ You can simply terminate with % though. \$\endgroup\$ – Martin Ender Jan 4 '17 at 22:27
  • \$\begingroup\$ @MartinEnder 00% is valid in Befunge-98 and results in 0 (or asks the user for the result in Befunge-93. \$\endgroup\$ – Pietu1998 Jan 4 '17 at 23:30
  • \$\begingroup\$ @MartinEnder Also, the last program will eventually terminate assuming finite memory. The Funge-98 spec mentions that { can reverse if it runs out of memory; nothing is said about normal pushing, and all interpreters seem to fail on OOM, but clearly memory limits are thought about in the language spec. \$\endgroup\$ – Pietu1998 Jan 4 '17 at 23:31
  • \$\begingroup\$ I think this could potentially be improved upon (maybe???) due to the presence of the p character, but it would take some work. You could do e%9 to get 5, but you would need a way to both print it and end the program, so i doubt it \$\endgroup\$ – MildlyMilquetoast Jan 5 '17 at 4:43
0
\$\begingroup\$

SmileBASIC, 12 snippets, 5 wildcards, 31 bytes

!.     '. is parsed as the number 0.0; taking the logical not gives 1
!.+!.  'Previous value added to itself
@Q||Q  '@Q is a label string and Q is a variable. For some reason, certain comparison/logical operations between strings and numbers return 3 rather than 1 or 0. 
4      '4
#TLIme 'Constant for the text color lime green, value is 5.
6      '6 (wildcard)
7      '7 (wildcard)
8      '8 (wildcard)
9      '9
&HA    'Hexadecimal A
11     '11 (one of them is a wildcard)
4*3    '4 multiplied by 3 (3 is wildcard)

I could've also used a variable instead of . (variables start at 0), and a string variable (like Q$) instead of @Q

Characters used: !!!#&*+...1449@AHILQQTem||

Wildcards used: 67813

unused characters: !!$$%()))):=@@OQTZ\\^`````````efpxy{||~~~~~~~~~

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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