2016 Time Capsule String: Climb The Integer Ladder

28

5

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.

Calvin's Hobbies

Posted 2017-01-04T04:41:49.910

Reputation: 84 000

1If 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?) – None – 2017-01-04T09:33:43.397

1Oh, 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. – None – 2017-01-04T09:36:18.923

1What about leading zeroes? Is 07 the same as 7? – Emigna – 2017-01-04T13:32:02.647

1It is really bugging me that the string contains neither - nor n... – devRicher – 2017-01-04T14:22:37.807

1Can "snippets" in stack-based languages leave their values on the stack? – FlipTack – 2017-01-04T17:23:21.460

@ais523 (1) I'll say no since it's less clear what "expression" means there and more difficult to test. (Maybe ask on meta about this.) (2) Treat the capsule characters as characters, not code points and not necessarily single bytes (depends on encoding). If your language doesn't support the time capsule characters, tough luck. – Calvin's Hobbies – 2017-01-05T01:04:01.880

@Emigna That sound ok, yes. – Calvin's Hobbies – 2017-01-05T01:04:23.697

Yes, according to http://meta.codegolf.stackexchange.com/a/8507/26997

– Calvin's Hobbies – 2017-01-05T01:05:38.640

Answers

10

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.

jimmy23013

Posted 2017-01-04T04:41:49.910

Reputation: 34 042

Which wildcards did you use? – Rɪᴋᴇʀ – 2017-01-05T15:06:44.217

@EasterlyIrk Edit. You can also use the wildcard counter in Dennis's answer.

– jimmy23013 – 2017-01-05T22:33:28.427

9

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)

Dennis

Posted 2017-01-04T04:41:49.910

Reputation: 196 637

5

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

user2428118

Posted 2017-01-04T04:41:49.910

Reputation: 2 000

1I think you can add 10. 0xA (with 0 being a new wildcard granted for reaching 10) – Arnauld – 2017-01-04T17:18:10.457

You can do (Q=!``)|Q for 1 to get an extra 1 somewhere. Not sure if that'll help though – ETHproductions – 2017-01-04T18:39:01.720

4

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

busukxuan

Posted 2017-01-04T04:41:49.910

Reputation: 2 728

4

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.

Stewie Griffin

Posted 2017-01-04T04:41:49.910

Reputation: 43 471

2

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.

FlipTack

Posted 2017-01-04T04:41:49.910

Reputation: 13 242

1

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

Emigna

Posted 2017-01-04T04:41:49.910

Reputation: 50 798

1

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.

Martin Ender

Posted 2017-01-04T04:41:49.910

Reputation: 184 808

1

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.

Marcus Dirr

Posted 2017-01-04T04:41:49.910

Reputation: 11

0

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.

PurkkaKoodari

Posted 2017-01-04T04:41:49.910

Reputation: 16 699

I don't think the last one is valid. Unless the challenge says otherwise, programs need to terminate. – Martin Ender – 2017-01-04T22:26:25.957

You can simply terminate with % though. – Martin Ender – 2017-01-04T22:27:09.760

@MartinEnder 00% is valid in Befunge-98 and results in 0 (or asks the user for the result in Befunge-93. – PurkkaKoodari – 2017-01-04T23:30:45.953

@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. – PurkkaKoodari – 2017-01-04T23:31:20.557

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 – MildlyMilquetoast – 2017-01-05T04:43:05.120

Nevermind, for some reason I thought those backticks were 's. There aren't enough push operations or math operators to eek out another . or , with put. – MildlyMilquetoast – 2017-01-05T04:51:05.560

0

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{||~~~~~~~~~

12Me21

Posted 2017-01-04T04:41:49.910

Reputation: 6 110