66
\$\begingroup\$

Print integers 0 to 100 (inclusive) without using characters 123456789 in your code.

Separator of numbers can be comma or white space (by default <blank>, <horizontal tabulator>, <newline>, <carriage return>, <form feed> or <vertical tabulator>).

Shortest code wins.

\$\endgroup\$
7
  • 16
    \$\begingroup\$ Many tricks are made possible by allowing 0. Which is what makes this challenge interesting, IMO. \$\endgroup\$
    – Arnauld
    Feb 23, 2021 at 17:08
  • 3
    \$\begingroup\$ I thought "do X without Y" questions weren't allowed anymore. \$\endgroup\$
    – Purple P
    Feb 24, 2021 at 3:34
  • 5
    \$\begingroup\$ @PurpleP They're allowed, but discouraged. Interesting ones are fine. \$\endgroup\$ Feb 25, 2021 at 0:06
  • 16
    \$\begingroup\$ Is there a requirement to stop printing at 100? \$\endgroup\$
    – spuck
    Feb 25, 2021 at 16:44
  • 2
    \$\begingroup\$ Can I use non-ASCII encoding? \$\endgroup\$
    – user100411
    Oct 17, 2021 at 20:36

170 Answers 170

3
\$\begingroup\$

Powershell, 18 bytes

0..[byte][char]'d'
\$\endgroup\$
4
  • 1
    \$\begingroup\$ -5 bytes Try it online! \$\endgroup\$ Feb 23, 2021 at 18:12
  • 1
    \$\begingroup\$ -9 bytes Try it online! \$\endgroup\$
    – Julian
    Feb 23, 2021 at 21:25
  • \$\begingroup\$ @ZaelinGoodman, Julian for some unknown reason I can't access TIO, I will update as soon as I can go, thanks! \$\endgroup\$
    – Wasif
    Feb 24, 2021 at 6:56
  • \$\begingroup\$ @Julian Wow, nice one!! \$\endgroup\$ Feb 24, 2021 at 13:00
3
\$\begingroup\$

Husk, 4 bytes

ŀc'e

Try it online!

Surprised Husk doesn't have a builtin for 100.

How it works

ŀc'e - Main function, no arguments
  'e - Character literal "e"
 c   - Convert to charcode; 101
ŀ    - Lowered range; [0, 1, ..., 100]
\$\endgroup\$
3
\$\begingroup\$

Befunge-98 (FBBI), 13 11 bytes

.0!+::'e%j@

-1 byte thanks to @ovs

-1 byte thanks to @PizgenalFilegav

Try it online!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ 'd is a byte shorter than aa*. \$\endgroup\$
    – ovs
    Feb 23, 2021 at 18:25
  • \$\begingroup\$ Also, using %j@ is a byte shorter than the conditional. \$\endgroup\$ Feb 24, 2021 at 7:00
  • \$\begingroup\$ @ovs I forgot to look at Befunge's tips :) thanks! \$\endgroup\$
    – Cinaski
    Feb 24, 2021 at 16:25
  • \$\begingroup\$ @PizgenalFilegav nice catch! But I don't quite get why the jump doesn't skip the first instructions, does it reset when wrapping around? \$\endgroup\$
    – Cinaski
    Feb 24, 2021 at 16:27
  • \$\begingroup\$ @Cinaski I'm not completely sure either, but I think it's because Befunge-98's wrapping behavior works by backtracking until it actually reaches the opposite side of the program, and it only happens after the jump is complete. \$\endgroup\$ Feb 24, 2021 at 17:34
3
\$\begingroup\$

Python 3, 96 bytes

import sys
n=0xb%0xa;m=0xa*0xa;p=lambda x:m if x>m else sys.stdout.write(str(x)+",")&p(x+n);p(n)

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ I don't think int(...) is needed around 0xa or 0xb etc. Also, you need to include the score in the post header (the number of bytes in case of code-golf). \$\endgroup\$
    – Bubbler
    Feb 25, 2021 at 7:14
  • \$\begingroup\$ 65 bytes Prints newline instead of ,, and doesn't have the trailing ,. Also, your solution didn't start from 0, it started from 1. This fixes that \$\endgroup\$ Feb 26, 2021 at 0:11
3
\$\begingroup\$

Japt, 2 bytes

òL

Try it online!

Calls the function ò on the variable U with the variable L as an argument. U is 0 when the program has no input, L is 100 whenever a program starts, and the function ò returns the inclusive range from "this" (U) to its first argument (L).

Also valid:

Calls the function ò on the variable L with no arguments. With no arguments ò returns the inclusive range from 0 to "this". This one ignores input, rather than requiring no input.

\$\endgroup\$
3
\$\begingroup\$

PHP, 26 bytes

print_r(range(0,0xA*0xA));

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Arn -h, 2 bytes

PS. You need to hand-type that flag because the permalink for flags is not working.

0|

Try it

Explained

0   # 0
 |  # concatenated with
    # (implicit) the range [1 .. 100]

Implicit output
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Im very late, but thanks for pointing out that bug. I'll fix it now \$\endgroup\$ Apr 11, 2021 at 2:27
3
\$\begingroup\$

Haskell - 31 19 bytes

Edit: From 31 bytes to 19 bytes, thanks to @binarycat's suggestion of using fromEnum instead of ord, which requires the Data.Char package.

Are imports cheating?

l=[0..fromEnum 'd']

Try it online!

Explanation:

Convert 'd' into it's ASCII integer value using the fromEnum function, which gives 100 and generate a list from 0 to 100.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ why import, fromEnum will do just fine. \$\endgroup\$
    – binarycat
    Mar 7, 2021 at 23:49
  • \$\begingroup\$ Didn't know that was a thing! I'm new to Haskell--Thanks for your suggestion :) \$\endgroup\$ Mar 7, 2021 at 23:52
  • \$\begingroup\$ you should probably also print the list, instead of just assigning it to a variable. \$\endgroup\$
    – binarycat
    Mar 7, 2021 at 23:59
  • \$\begingroup\$ You can get rid of the 'l=' if you run it in GHCi, for a saving of 2 bytes. \$\endgroup\$
    – Penguino
    Aug 2, 2021 at 23:29
3
\$\begingroup\$

javascript 77 bytes

let i=0;while(true){console.log(i);if(i.toString().includes('00'))break;i++;}
\$\endgroup\$
2
  • 4
    \$\begingroup\$ For starters, convention says you should include a bytecount on your posts. A good website for this is tio.run which can automatically format posts for you. Also, you could easily remove a lot of the whitespace, eg: -6 bytes. Apart from the basics, heres a handy guide for golfing specifically in JS. Good luck \$\endgroup\$
    – Underslash
    Jul 8, 2021 at 2:48
  • \$\begingroup\$ Thank you ill do it in my next posts :) \$\endgroup\$
    – moum bou
    Jul 8, 2021 at 4:52
3
\$\begingroup\$

Shakespeare Programming Language, 218 bytes

,.Puck,.Ajax,.Act I:.Scene I:.[Exeunt][Enter Puck and Ajax]Puck:Open heart.You is the sum ofyou a cat.Ajax:You is twice the sum ofa big big cat a cat.Speak mind!You is the square ofyou.Is I nicer you?If notlet usAct I.

Try it online!

This is a golfed version based off of Dr Lemniscate's answer, with several non-trivial modifications, such as using only one Scene and not initialising characters. This also includes the character and program introduction section, which was neglected.

Explanation

,.Puck,.Ajax,.Act I:.Scene I:.     # Introduce the characters and the play itself.
[Exeunt][Enter Puck and Ajax]      # Enter the main characters
Puck: Open heart.                  # Print Ajax's value as a number
      You is the sum ofyou a cat.  # And increment it
Ajax: You is twice the sum ofa big big cat a cat.      # Set Puck to 2*(8+2)=10
      Speak mind!                  # Print as a character (a newline)
      You is the square ofyou.     # Square the value to 100
      Is I nicer you?              # Compare the value against Ajax's
      If notlet usAct I.           # And loop if the value is <= 100
\$\endgroup\$
3
\$\begingroup\$

JavaScript (V8), 52 39 bytes

for(i=0;!print(i)>=~-(''+i++).length;);

Try it online!

Thanks Jo king

Original version :

JavaScript (V8), 52 48 bytes

for(i=0;i<=(c="    ".length)*-~c*-~c;)print(i++)

Try it online!

Not the shortest by any margin

Explanation :

for(i = 0; // simple for loop 
    i <= (c="    ".length)*~-c*~-c;
        // c = "    ".length ---> 4 
        // * -~c * -~c       ---> -~c => 5 => 4 * * 5 * 5 ==> 100
        ;)print(i++)          ---> end for loop and print i, then increment by 1  

Alternately :

JavaScript (V8), 47 bytes

_=>[...Array((c="    ".length)*-~c*-~c).keys()]

Try it online!

That prints up to 99 for 51 bytes,

_=>[...Array((c="     ".length)**~-~-c-c*c).keys()]

Prints upto 100 but byte count is 54.

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

AWK, 35 34 31 bytes

END{for(i;i<=0xA**2;)print i++}

Try it online!

-1 byte thanks to me

-3 bytes thanks to @cnamejj

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can remove the i=0 statement since AWK uses an initial value of 0 for any variable use in a mathematical expression before it's set. \$\endgroup\$
    – cnamejj
    Nov 8, 2021 at 8:53
  • 1
    \$\begingroup\$ And 0xA**2 saves another byte. (I tried to edit the previous comment but wasn't able too since more than 5 mins had passed.) \$\endgroup\$
    – cnamejj
    Nov 8, 2021 at 9:00
3
\$\begingroup\$

KonamiCode, 54 50 55 bytes

v(>)>(^)v(^^^>^^)S(^>>^)>(>)L(>)<<<v((>))>(^)<<>(>)B(>)

A version with an explanation:

[You actually do need to inititalize address 0, my mistake. Also, my original version did not print 0.]

v(>) [Inititalizes address 0]
>(^) [Sets address pointer to 1, this is where the space character wil be held]
v(^^^>^^) [Writes 32 (a space) to memory]
S(^>>^) [Sets the comparison buffer to 101]
>(>) [Back to address 0]
L(>) [Loop marker]
<<< [Output the counter at address 0 as a number]
v((>)) [Increase the counter by 1]
>(^) [Goes to the space]
<< [Output the space]
>(>) [Back to 0]
B(>) [Done!]
\$\endgroup\$
3
\$\begingroup\$

Risky, 3 2 bytes

0:--

Try it online!

range(100 - -1)
\$\endgroup\$
3
\$\begingroup\$

Vyxal, 3 bytes

₁ɾ⁋

Try it Online!

enter image description here

I guess so.

\$\endgroup\$
3
\$\begingroup\$

MATL, 6 5 6 bytes

O'd'&:

Try it out at MATL Online

Explanation

O     % Letter O which is a pre-defined literal for zero
'd'   % String literal, 'd' (ASCII 100)
&:    % Create an array from 0...100
      % Implicitly print the result
\$\endgroup\$
2
  • \$\begingroup\$ I think it's supposed to range from 0 to 100 -- I made the same mistake myself. \$\endgroup\$
    – Giuseppe
    Feb 24, 2021 at 12:16
  • \$\begingroup\$ @Giuseppe Good call, I saw the 1,2,3,4,5,... in the description and got confused! \$\endgroup\$
    – Suever
    Feb 24, 2021 at 14:31
3
\$\begingroup\$

Trilangle, 26 bytes

'0.vj..!"/@.)e.,>-./.._..'

Test it in the online interpreter!

Trilangle is a 2-D language inspired by Hexagony. It has its own instruction set, and two major differences when it comes to code/memory layout:

  • The bounding box of the code is a triangle rather than a hexagon
  • Memory is stored in a stack* rather than a grid.

The memory structure isn't a pure stack, as it's possible to look (but not write) arbitrarily far down the stack. This feature makes it Turing-complete.

Explanation

When unwrapped into the triangular grid, this code is:

      '
     0 .
    v j .
   . ! " /
  @ . ) e .
 , > - . / .
. _ . . ' . .

The IP starts at the north corner, moving southwest.

For lack of a fancy tool, have a diagram I made in paint:

The IP initially follows the red path, hitting the following instructions:

  • '0: Push the number 0 to the stack
  • v: Change the direction of control flow
  • !: Print the number on top of the stack in decimal
  • ): Increment the top of the stack
  • .: No-op
  • ': Part of a "push" instruction

After hitting the partial "push" instruction, the IP walks off the edge of the board and continues one diagonal to its left -- on the green path.

  • 0: The rest of the push instruction; pushes another 0
  • j: The indexing operator. The stack now contains two copies of the same number (1 more than the value that was printed last).
  • "e: Push the value of the character 'e' (101 in decimal)
  • /: Changes the direction of control flow
  • .: No-op again
  • -: Subtract the two values on top of the stack. If the last value printed was n, the stack now contains [n+1, n-100].
  • >: Branch. If the value on top of the stack is positive or zero, it takes the yellow path; if the value is negative, it takes the blue path.

On the yellow path, the next instruction is @, which terminates the program. Continuing on the blue path, the instructions are:

  • _: Changes the direction of control flow

  • ,: Pop from the stack

    [Run off the edge and continue on the magenta path]

  • A few more NOPs

  • /: Changes the direction of control flow again. It runs off the edge and continues at v, where it merges with the red path.

Is this optimal?

I'm not sure. Given the number of NOPs in the code I'd be unsurprised if this can be reduced, but I don't think I can make the entire triangle smaller (reducing its side length to 6) without substantially restructuring it.

\$\endgroup\$
5
  • \$\begingroup\$ As per specification you may not use commas (,). \$\endgroup\$ Sep 6, 2023 at 14:00
  • 3
    \$\begingroup\$ @KaiBurghardt Only the digits 1–9 are forbidden. Several other answers include commas. \$\endgroup\$
    – Bbrk24
    Sep 6, 2023 at 14:32
  • \$\begingroup\$ I am afraid that – as far as I have experienced it – PPCG is pretty conservative as regards to interpretation of specifications. The fact that submissions in 24 distinct languages used commas is beside the fact. \$\endgroup\$ Sep 6, 2023 at 16:00
  • 1
    \$\begingroup\$ @KaiBurghardt Clearly, those commas in the code block in the specification are meant to separate the different characters which are not allowed. Otherwise, only one comma would be present. I think you're taking the challenge too literally \$\endgroup\$
    – noodle man
    Sep 6, 2023 at 16:56
  • \$\begingroup\$ @noodleman The referenced PPCG-Meta-post concerns loopholes. As far as I can tell, Bbrk24 did not achieve a lower score by taking the challenge too literally (i. e. exploiting a loophole). At any rate, against all odds a suggested edit of mine did get accepted so there is no ambiguity no more. I wonder, however, which submissions did intentionally observe the no-comma restriction (mine did). \$\endgroup\$ Sep 7, 2023 at 8:40
3
\$\begingroup\$

Piet + ascii-piet, 39 bytes (7×6=42 codels)

Slightly cheating to use a language which isn't even text, but even the ascii-piet encoding of it contains no digits.

tlrtmE rraaD ? aaAdd? aAd ?aAk   Aletrq

This ascii-piet compiles into this piet program:

A piet program

Try Piet online!

\$\endgroup\$
3
\$\begingroup\$

makina, 58 bytes

v<<<<<<LtIaaa;
>Pu>>>?= LCS
UC>n0;H>>^>>n0;
     UPJ >JC>U

I AM BUTTER FEED ME BOT

I'm a bot. This answer was posted by a human to get me enough reputation to use chat.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I'm actually really proud of this answer, given how limited makina is in terms of operations available \$\endgroup\$
    – Ginger
    Nov 15, 2023 at 16:50
2
\$\begingroup\$

Clojure, 24 bytes

(apply pr(range(int\e)))

Try it online!

If it is acceptable that output is wrapped in parentheses, then we can remove apply for -6 bytes.

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

CJam, 6 bytes

'ei,:p

Try it online!

How it works

'e    e# Push character "e" (which has code point 101)
i     e# Convert to integer. Gives 101
,     e# Range (non-inclusive, starting at 0). Gives [0 1 2 ... 100]
:p    e# For each entry: print with newline
\$\endgroup\$
2
\$\begingroup\$

Pyth, 9, 8, 5 bytes

@hakr46's solution

Uh*TT

Try it online!


original:

U+*TT^Z

Try it online!

Outputs a list. If the separator must be a single character, 11 bytes 6 bytes

My first golf. Pretty happy about it! Makes use of the fact that anything to the power of 0 is 1.

-3/5 bytes thanks to @hakr46 :D

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Pyth has an increment instruction, h. Also, separating a list by newlines is done with j with only one argument. These let you save 3 bytes to output the list or 5 bytes to output each number with a single character separator. \$\endgroup\$
    – hakr14
    Feb 23, 2021 at 18:25
  • 1
    \$\begingroup\$ pyth.herokuapp.com's interpreter doesn't work anymore, but it still has searchable documentation, so I like to keep it open when golfing Pyth. \$\endgroup\$
    – hakr14
    Feb 23, 2021 at 18:27
  • 1
    \$\begingroup\$ @hakr14 May I introduce you to pythtemp.herokuapp.com Interpreter that works WITH documentation \$\endgroup\$
    – Scott
    Feb 26, 2021 at 0:43
  • \$\begingroup\$ @Scott :O thank you so much... \$\endgroup\$
    – hakr14
    Feb 26, 2021 at 1:12
2
\$\begingroup\$

F# (.NET Core), 35 bytes

Seq.iter(printfn"%A"){0..(int 'd')}

Try it online!

(Too bad it wasn't only to 99, could have gotten rid of the Seq.iter due to printing truncation...)

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

BRASCA, 9 bytes

Hr,n[lon]

Try it online!

Explanation

Hr         - Push range(0,100)
  ,        - Reverse stack
   n       - Print the 0
    [   ]  - While not zero:
     lon   -    Print a newline and the next number
\$\endgroup\$
2
\$\begingroup\$

Alice, 17 bytes

aa*r\
 @Q
&d\
 O

Try it online!

Explanation:

a       Push 10
 a      Push 10
  *     Pop x. Pop y. Push x * y
   r    Pop n. Push all integers from 0 to n, inclusive
    \   Switch to Ordinal mode. Redirect command flow to the southeast
        Command flow hits the boundary of the grid and is reflected to the southwest
   Q    Reverse the order of the stack
  \     Switch to Cardinal mode. Redirect command flow to the west
 d      Push the number of elements currently on the stack
&       Pop n. Add n to the iterator queue
        Command flow hits the boundary of the grid and wraps
  \     Switch to Ordinal mode. Redirect command flow to the southwest
 O      Pop s. Print s as a string followed by a newline 
          (Gets executed the number of times stored on the top of the iterator queue)
        Command flow hits the boundary of the grid and reflects to the northwest
&       Pop s. Add s to the iterator queue
          (Everything between here and the end of the program is just the command flow 
          bouncing around until it reaches the @)
        Command flow hits the boundary of the grid and reflects to the northeast
  *     Pop b. Pop a. Push the concatenation of a and b
          (Executes 0 times because & added an empty string to the iterator queue)
        Command flow hits the boundary of the grid and reflects to the southeast
   Q    Reverse the order of the stack
        Command flow hits the boundary of the grid and reflects to the southwest
        Command flow hits the boundary of the grid and reflects to the northwest
  \     Switch to Cardinal mode. Redirect command flow to the south
        Command flow hits the boundary of the grid and wraps
  *     Pop x. Pop y. Push x * y
  @     Terminate the program
\$\endgroup\$
2
\$\begingroup\$

PHP, 29 bytes

<?=join(',',range(0,ord(d)));

Explanation

ord(d) // return integer value of ASCII character 'd'
range  // create array from A to B, inclusive
join   // glue array values together using comma as separator
<?=    // output

Try it online!

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

Wolfram Language (Mathematica), 29 bytes

included more for the amusing built-in than the byte count, though this would be something like 9 bytes in the hypothetical mthmca golfing language.

Range[0,FromRomanNumeral@"C"]

Try it online!

And similar, but longer

Range[0, Interpreter["SemanticNumber"]@"hundred"]
\$\endgroup\$
1
  • \$\begingroup\$ +1 for use of stupid built-ins \$\endgroup\$
    – des54321
    Mar 18, 2022 at 14:18
2
\$\begingroup\$

C (gcc), 35 bytes

f(i){printf("%d ",i)&'#'?f(++i):0;}

Try it online!

Let's go recursively!

\$\endgroup\$
2
  • \$\begingroup\$ Would somebody smarter than me explain how this knows to stop counting? \$\endgroup\$ Feb 25, 2021 at 16:04
  • \$\begingroup\$ @MichaelStern - printf returns the number of characters printed - when we print 100, it returns 3. '#' is ASCII 35. 3 & 35 == false; This would work with any power of 2 value + 3 (lowest 2 bits set) - 3, 7, 11, 19, 35, 67, 131, etc. So, 'C' would also work. \$\endgroup\$ Feb 25, 2021 at 19:18
2
\$\begingroup\$

Tcl, 38 bytes

puts 0
time {puts [incr i]} [incr u]00

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Unfortunately it is not 1 to 100. I could do it even cheaper: tio.run/##K0nO@f@/JDM3VaG6oLSkWCE6My@5SCEzthbKKo01MPj/HwA \$\endgroup\$
    – sergiol
    Feb 25, 2021 at 20:12
  • \$\begingroup\$ I was about to suggest the code from your comment plus a lame puts 0. Still shorter. \$\endgroup\$
    – manatwork
    Feb 25, 2021 at 20:18
  • \$\begingroup\$ @manatwork: Yes it is shorter, thanks. \$\endgroup\$
    – sergiol
    Feb 25, 2021 at 20:23
2
\$\begingroup\$

T-SQL, 65 64 bytes

SELECT number FROM spt_values WHERE number<ASCII('e')AND'P'=type

The master database on any SQL server contains a system table called spt_values that (among other things) contain the numbers 0 to 2047. To cap the output I used ASCII('e'), which is 101.

Let me know if you know of a shorter way to generate the number 100 or 101.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Can't ) touch the AND keyword just as ' touches it? Because rewriting the expression as number<ASCII('e')AND'P'=type could save 1 character. \$\endgroup\$
    – manatwork
    Feb 25, 2021 at 21:17
  • \$\begingroup\$ Yep, that rearrangement works, @manatwork. Thanks! \$\endgroup\$
    – BradC
    Feb 25, 2021 at 21:27

Your Answer

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