Count up from 0 to 2017 without numbers in your source

-9

2

This question was profoundly inspired by Joe Z's question.

But, with a twist...

So, now that it's almost 2017, it's time for a code question involving the number 2017.

Your task is to make a program that counts up from 0, printing each number until it reaches 2017. without using any of the characters 012345678 or 9 in your code; and without using any variables such as the date or time or a random number.

Acceptable Output

The output of your code must follow the following format:

[number]
[number]
[number]
etc.

A number, then a line feed, then repeat.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Example Output:

0
1
2
3
4
...
2016
2017

cascading-style

Posted 2016-12-12T21:54:18.490

Reputation: 251

This is rather vague. How should the numbers be printed? What constitutes an external variable? You give two examples but never define it. What constitutes a valid token? – Conor O'Brien – 2016-12-12T21:57:23.133

@ConorO'Brien please read the linked post. – cascading-style – 2016-12-12T21:58:05.710

3Questions should be self-contained. You need to specify these in your own post, should the old question be unavailable in the future. – Conor O'Brien – 2016-12-12T21:58:46.543

@ConorO'Brien Ok, i am editing it now. – cascading-style – 2016-12-12T21:59:24.667

What is so wrong with my question? please let me know so that I can fix it.@Dennis @ConnorO'Brien – cascading-style – 2016-12-12T22:13:40.890

For starters, you still haven't ruled which output formats are acceptable. Do we have to print then numbers separated by newlines? Can we return a list of numbers from a function? – Dennis – 2016-12-12T22:16:40.233

That said, even with a perfect specification, it might still be considered a duplicate of the previous challenge. The difference is that we cannot simply print 20 and 17 this time; it has to be a single integer. – Dennis – 2016-12-12T22:20:47.770

14

Don't be tricked the printing 2014 challenge having masses of votes. By modern standards, it's pretty awful, and I'd expect it to get a poor reception if posted today. See Using old challenges as a model as a thing to avoid, as well as Do X without Y.

– xnor – 2016-12-12T22:21:27.120

1^ Agreed. Come up with your own unique challenge. – mbomb007 – 2016-12-12T22:32:28.793

1Too bad this was closed. I just came up with a 7 char/8 byte solution. – Adám – 2016-12-13T10:49:17.787

2By the way, you also posted this (and suggested an edit to my 2014 question) about 19 days too early. The New Year's Puzzle is supposed to be posted exactly on the new year, wherever it happens to be where you live. – Joe Z. – 2016-12-13T16:40:34.417

1Also, I think you just accepted my answer too quickly. I'd suggest waiting at least 7 days :) – Erik the Outgolfer – 2016-12-15T15:46:21.960

In order to enter, I have to use line numbers for the Sinclair ZX81 - even if I write it in assembly. Will this still be allowed? – Shaun Bebbers – 2017-04-04T07:05:07.957

Answers

3

Jelly, 6 bytes

“¬×’ḶY

Try it online!

Explanation:

“¬×’ḶY Main link. Arguments: 0
“¬×’              2018
    Ḷ             Range [0..z)
     Y            Join z by newlines

Erik the Outgolfer

Posted 2016-12-12T21:54:18.490

Reputation: 38 134

6

PowerShell v2+, 15 bytes

''..+[char]'ߡ'

UTF-8 code point 2017, ߡ, functions as our upper bound. We turn it from a string into a char with [''], then to an int with +. The lower bound '' is implicitly cast to 0. Thus, this is the range operator .. from 0 to 2017. Default Write-Output prints each number with newlines between.

AdmBorkBork

Posted 2016-12-12T21:54:18.490

Reputation: 41 581

1What a beautifully golfed answer! – cascading-style – 2016-12-12T22:04:40.320

3

APL (Dyalog APL), 13 bytes

Requires ⎕IO←0 which is default on many systems.

⍳⎕UCS'ߢ'

TryAPL online!

N first indices, where N is

⎕UCS the Unicode code point of

'ߢ' this character

Adám

Posted 2016-12-12T21:54:18.490

Reputation: 37 779

Oops, I misread – Conor O'Brien – 2016-12-12T22:16:07.793

3

Java, 99 bytes

Hobbyist programmer here. This is my first golf so apologies if I mess things up. Of course since I wrote in Java my code is going to be very large, but I think this may be as far as Java can go.

Golfed:

interface D{static void main(String[]z){for(int i='a'-'a';i<'ÿ'*''+'é';)System.out.println(i++);}

Ungolfed:

interface D{
    static void main(String[]z){
        for(int i='a'-'a';i<'ÿ'*''+'é';) //Between the seemingly empty quotes is an enquiry character with an ASCII value of 7, which has been included in the byte count and post.
            System.out.println(i++);
    }
}

Explanation: This solution abuses the interaction Java's compiler has with chars. Since Java interprets ASCII characters as bytes, I can use that fact to do arithmetic without actually ever using a number. The y with a diaeresis ASCII 255, enquiry is 7, and the acute e is 233 (so I can have 2017 be included). Hopefully this isn't too cheaty to do!

Zavada

Posted 2016-12-12T21:54:18.490

Reputation: 189

Welcome to ppcg! Nice first post! – Rɪᴋᴇʀ – 2016-12-22T03:51:09.557

@Easterly Irk Cheers :) Hope I didn't do too poorly! Is there anything I need to know going further into golfing? – Zavada – 2016-12-22T04:26:57.990

As you noted, Java isn't always the best language to golf in, but that's okay. Also, as you might have seen, many users on this site create their own languages to golf in. The consensus on that is as long as the language predates the challenge, that's fine. That's about it, hope you have fun and stay here with us! – Rɪᴋᴇʀ – 2016-12-22T16:50:51.550

2

05AB1E, 8 bytes

žCžw<-Ý»

Try it online!

Magic Octopus Urn

Posted 2016-12-12T21:54:18.490

Reputation: 19 422

2

MATL, 15 11 bytes

4 bytes saved thanks to @Luis

'? 'pQQ:q"@

Try it Online!

Suever

Posted 2016-12-12T21:54:18.490

Reputation: 10 257

@LuisMendo You're absolutely right! My golf skills are apparently getting rusty – Suever – 2016-12-14T14:26:09.560

You need more practice :-P – Luis Mendo – 2016-12-14T17:26:12.850

2

Labyrinth, 49 43 40 bytes

))::+:#:*:
@        (
(\"))****(
{ }
)!:

Try it online!

Robert Hickman

Posted 2016-12-12T21:54:18.490

Reputation: 661

2

7, 29 bytes, 78 characters

Not going to win, but I had fun writing it. 7 uses a 3-bit character set that packs 8 characters into 3 bytes. Here's the program in octal encoding (which is most natural for the language):

770267133177162277266362217240522405240540562240540554240524052405052405405513

and here's how it looks on disk (via an xxd dump); looking on the right, we can verify that the file contains no digits:

00000000: fc2d cb67 f392 fd6c f247 a82a 5055 0582  .-.g...l.G.*PU..
00000010: e4a0 b05b 1415 4154 1455 0582 d2         ...[..AT.U...

Try it online!

Underload is the brainfuck of stack-based languages, and 7 is a variant of Underload modified to provide I/O capabilities and to reduce the size of the command set. (The command set had to be modified to allow for things like outputting mismatched parentheses.) So this is an example of how to write this program in a very primitive and low-level language.

Here's how the program works:

77026

We start by pushing the stack element 02, escaped once (thus it'll still appear as 02 on the stack; normally there's one level of unescaping). To push a stack element in 7, you precede it with a 7, and enclose any parts you want to escape in 76.

7 133  17 716 22 77266 36
        ( ( )    (( ))  )

The rest of the program is all stored in one large stack element. (In 7, there's no way to write code that runs immediately; you have to start by pushing it as a literal to the stack, then rely on it getting appended to the program implicitly when the program runs out of space.) We start by discarding the large stack element in question (13), then outputting the element below (3); that's 02. The first output of the program sets the output format the program uses. In this case, we're using output format 0, "integers". That accounts for (and removes) the zero. The output format we're using works by counting the number of 7s and 1s in the output string, and subtracting the number of 6s and 0s, to produce the integer to output; in this case, the string 2 has no 0s, 1s, 6s, or 7s, so it outputs 0. Finally, a trailing 2 (in this output format) produces a newline (the output would "naturally" be space-separated). After that, we push a large literal to the stack. This will eventually be used as a loop body, so we'll consider it when it runs.

22 1724052240524054056 2240540554240524052405052405405

Some people here may be used to Underload numerals from a previous challenge. 7 numerals are fairly similar. In the linked challenge, the only characters used were : and *; numbers represented like that can translate into 7 directly, with 2 serving the role of : and 405 serving the role of * (note that it's actually equivalent to Underload's ~*, but the two act identically in this context). Thus, given a number n, you can add 1 to it using 2n405, and you can multiply two numbers by appending them to each other; the null string is 1. One thing the linked challenge didn't mention, though, is exponentiation. This works a little differently in 7 than in Underload, but the same basic principles are in use in each case. Additionally, in 7, you can handle addition via putting code between the 4 and 05 (something that's more verbose in Underload because you can't put code inside the *). So we can restructure this part of the program like this:

2 
   2
    17         start a new number (=1)
      2405     ×2                 (=2)
      2        ×(1          (=1)
         2405     ×2        (=2)
         2405     ×2        (=4)
      405       +1          (=5)) (=10)
     6         end of the new number
     2         ×(1          (=1)
        2405      ×2        (=2)
     405        +1          (=3)) (=3)
    5          exponentiate (10 ^ 3 = 1000)
   4           +(1          (=1)
     2405         ×2        (=2)
     2405         ×2        (=4)
     2405         ×2        (=8)
   05           )                 (=1008)
   2405        ×2                 (=2016)
405            +1                 (=2017)

The rest of the program is:

5 13

The 5 starts a loop, running the stack literal we pushed earlier 2017 times. Finally, the 13 pops the top stack element, meaning that the stack is now empty and the program ends.

So what does the loop body do? Here's how it decodes:

716      Append a 1 to TOS
22       Make two more copies of the TOS
77266    Append a 2 to TOS
3        Output TOS, discard top two stack elements

Appending a 1 will increase the numerical value (initially zero) that numeric output will see the stack as having. We make two temporary copies, and append a 2 (to provide the newline required by the question). Then we output it, discarding the temporary copies in the process. Doing this 2017 times will thus count from 1 to 2017. We outputted the 0 earlier, thus completing the program.

user62131

Posted 2016-12-12T21:54:18.490

Reputation:

1without numbers in your source – Roman Gräf – 2016-12-14T11:25:49.783

@RomanGräf: .-.g...l.G.*PU....[..AT.U... doesn't seem to contain numbers to me. (Non-ASCII and unprintable characters have been replaced with . there, but aren't digits by definition; all the digits are in ASCII.) The commands are all named after digits (when they have names at all), but none of them appear literally in the source itself. – None – 2016-12-14T14:03:28.410

Oh, I only read the octal translation. – Roman Gräf – 2016-12-15T10:55:53.633

2

><> (Fish) 19 bytes

iaa,+:n:"#:"*d-=?;ao!

very simple, uses ascii chars to generate the number 2017 then compares to an increasing counter that gets printed.

i is input but without one becomes -1 a = 10 so aa, is 1 (10 div 10) "#:" becomes (# multiply :) which makes 2030 which we take 13 (d) from to make 2017 (This number is a prime so we can't save bytes here).

Teal pelican

Posted 2016-12-12T21:54:18.490

Reputation: 1 338

2

Java, 147 bytes

Call with no cmd args

class t{public static void main(String[]a){int i=a.length,j=++i,h;j+=i--;h=j*j*j*j*j;j=h*j*j*j*j*j*j-(--h);j++;for(;i<j;)System.out.println(i++);}}

Roman Gräf

Posted 2016-12-12T21:54:18.490

Reputation: 2 915

2

Python 3, 32 bytes

print(*range(ord('ߢ')),sep='\n')

user67719

Posted 2016-12-12T21:54:18.490

Reputation:

2

(K+R)eg, 9 bytes

ߡï(.\
,

Explanation:

ߡ      # Push 2017
 ï     # Count all the way from 0
       # Due to the irritating output-without-newline:
  (    # Repeat the length of the stack times:
   .   # Output the top of the stack
    \ ,# Output 1 newline

TIO

user85052

Posted 2016-12-12T21:54:18.490

Reputation:

1

JavaScript (ES6), 52 bytes

for(n=x=+[],i=++x+x+''+n;n<i+i-x-x;)console.log(n++)

There's not much to say about it:

for(
  n = x = +[],              // n = x = 0
  i = ++x + x + '' + n;     // i = 1 + 1 + '' + 0 = "20"
  n < i + i - x - x;        // n < "2020" - 1 - 1 <=> n < 2018
)
console.log(n++)

Arnauld

Posted 2016-12-12T21:54:18.490

Reputation: 111 334

1It's acceptable for javascript answers to use alert() instead of console.log() which would save you a few bytes. – Robert Hickman – 2016-12-13T23:11:02.057

1

Stax, 6 bytes

ÇîHtUá

Run and debug it

Use packing to avoid appearance of the digits.

Weijun Zhou

Posted 2016-12-12T21:54:18.490

Reputation: 3 396

0

Japt -R, 5 4 bytes

#ߢo

Test it

Shaggy

Posted 2016-12-12T21:54:18.490

Reputation: 24 623

0

W n d, 7 bytes

♦kb-╖úÜ

Explanation

Uncompressed:

2018   M % Foreach in the range 1..2018:
    a1-  % Return the current item - 1

Flags:n  % Join the output with newlines
```

user85052

Posted 2016-12-12T21:54:18.490

Reputation: