74
\$\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
    Commented Feb 23, 2021 at 17:08
  • 3
    \$\begingroup\$ I thought "do X without Y" questions weren't allowed anymore. \$\endgroup\$
    – Purple P
    Commented Feb 24, 2021 at 3:34
  • 5
    \$\begingroup\$ @PurpleP They're allowed, but discouraged. Interesting ones are fine. \$\endgroup\$
    – rydwolf
    Commented Feb 25, 2021 at 0:06
  • 16
    \$\begingroup\$ Is there a requirement to stop printing at 100? \$\endgroup\$
    – spuck
    Commented Feb 25, 2021 at 16:44
  • 2
    \$\begingroup\$ Can I use non-ASCII encoding? \$\endgroup\$
    – user100411
    Commented Oct 17, 2021 at 20:36

173 Answers 173

6
\$\begingroup\$

AWK, 26 bytes

{for(;a<=0xa*0xa;)$a=a++}a

Try it online!

Thanks to xnor for pointing out a brainfart (since fixed) in the original

This works by using 0xa*0xa to compute 100, then assigns each positional variable to it's own sequential number. Then the a without a code block (evaluates as truthy since a is 100) prints all the positional arguments separated by a space.

To be honest, I'm not 100% sure why the 0 prints but it does. :)

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I don't think that the 1 is allowed unfortunately \$\endgroup\$
    – xnor
    Commented Feb 26, 2021 at 17:34
  • \$\begingroup\$ Wow, that was dumb. :) Thanks! The fix was simple enough and didn't change the length of the code, \$\endgroup\$
    – cnamejj
    Commented Feb 26, 2021 at 19:37
  • 1
    \$\begingroup\$ Why the zero prints: tio.run/##SyzP/v@/Oi2/… \$\endgroup\$ Commented Feb 28, 2021 at 11:36
6
\$\begingroup\$

Whitespace, 58 bytes

Another in the theme of "this language doesn't even care about digit characters".

   

  
 
 	
 	   	 	 
	
     	
	    
    		  	 	
	  	
		

Try it online!

The program with comments:

[Push  0 
][Label
  
][Dup 
 ][PrintNum	
 	][Push  10 	 	 
][PrintChar	
  ][Push  1 	
][Add	   ][Dup 
 ][Push  101 		  	 	
][Subtract	  	][JmpNeg
		
]

Try it online!

\$\endgroup\$
6
\$\begingroup\$

Vim, 20 bytes

i0<esc><C-A>s<C-R>=range(<C-R>"0<C-R>")

Try it online!

Trying to improve on Razetime's answer, I stumbled upon the range function, which works wonders for this task. i<C-R>=range(101)\n would print the numbers we want, we just need to be a little creative to do it without 1.

Explanation

i0<esc><C-A>s<C-R>=range(<C-R>"0<C-R>")
i0<esc>                                    Insert a single 0
       <C-A>                               Increase it to a 1
            s                              Cut the 1 and go back to insert mode
             <C-R>=                        Write the result of the following function
                   range(             )    A range of numbers from 0 to N-1
                         <C-R>"            The last text that was deleted (1)
                               0           0
                                <C-R>"     1 again
\$\endgroup\$
1
  • \$\begingroup\$ -4 bytes by using tab autocomplete on the range() function. Also, it doesn't work on TIO, but if you start Vim with the +startinsert flag, you don't need the i at the beginning and save another -1 bytes: vim +startinsert testfile \$\endgroup\$ Commented Apr 26, 2021 at 14:03
6
\$\begingroup\$

, 96 93 bytes

^+++(###....+###....+++<..#+...-....###+.@#+...$)+).>+++.$#+...^##=.+###.-#+....+)<++(-+##++>

Unwrapped:

        ^ + + +
        ( # # #
        . . . .
        + # # #
. . . . + + + < . . # + . . . -
. . . . # # # + . @ # + . . . $
) + ) . > + + + . $ # + . . . ^
# # = . + # # # . - # + . . . .
        + ) < +
        + ( - +
        # # + +
        > . . .

I'm not able to provide a direct link, but here you should be able to fork the project and replace the script.txt with either of the above scripts.

\$\endgroup\$
1
  • \$\begingroup\$ NO idea what this is doing but it looks so pretty 😍 +1 \$\endgroup\$
    – roblogic
    Commented Mar 6, 2021 at 4:14
6
\$\begingroup\$

Befunge-93, 16 13 bytes

Thanks to @Cinaski for saving 3 bytes with \! instead of "ba"-.

:.\!+:"d"`#@_

Try it online!

Uses \! to NOT the 0 at the bottom of the stack and uses that to increment the loop, then tests if the counter is greater than d to end. Certainly not the shortest answer, but this is my first golf challenge, and I wanted to practice Befunge, which I decided to pick up yesterday. This is also my first time trying a stack-based language, and I'm having a lot of fun with it.

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to Code Golf. Nice first answer! \$\endgroup\$
    – rydwolf
    Commented Mar 11, 2021 at 15:04
  • 1
    \$\begingroup\$ Welcome to the site! You can save 3 bytes by replacing "ba"- with \! 13 bytes \$\endgroup\$
    – Cinaski
    Commented Mar 11, 2021 at 15:25
6
\$\begingroup\$

Wolfram Language (Mathematica), 15 14 11 bytes

=Range[0,LL

-1 byte from Imanton1

Mathematica interprets the = prefix as a call to Wolfram Alpha (auto-converting it to the orange glyph seen below), which in turn interprets "LL" as a Roman numeral for 100. I used "LL" because this doesn't work with the shorter "C".

enter image description here

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can shave off a byte, since WA uses free-form input, you can drop off the final closing bracket and it can still figure it out. =Range[0,hecto \$\endgroup\$ Commented Oct 17, 2021 at 18:36
6
\$\begingroup\$

Python 3 20 Bytes

print(*range(*b'e'))

How it works? Basically, doing *b'char' is equivalent to ord('char'), and in this case ord('e') is equal to 101 ; Lets re-create the ord() function!

Ord Function Recreation (Not the answer! Just a demonstration on how ord() works)

ord=lambda x:(int(*bytes(x, 'ascii')))

As you can see it works! You can test this yourself here.

Python 3 25 Bytes

print(*range(0xa*0xa-~0))

How it works? 0xa = 10, ~0 = -1, -~0 = 1 (equivalent to -1*-1)

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Welcome to Code Golf! Nice first answer. But 'utf8' contains an 8. \$\endgroup\$
    – alephalpha
    Commented Oct 29, 2021 at 12:24
  • 1
    \$\begingroup\$ Yes ; but that was just a explanation on how ord works. Not the answer itself. \$\endgroup\$ Commented Oct 29, 2021 at 12:47
  • \$\begingroup\$ Even though not needed ; I decided to change the ord() explanation from 'utf8' to 'ascii' just to clear up some confusion. Thank you. \$\endgroup\$ Commented Oct 29, 2021 at 12:53
6
\$\begingroup\$

Desmos, 25 bytes

o=0
o->[0...eeeln(eeeee)]

Not sure if this is an acceptable form of output but it's still an interesting answer imo. Click the right arrow (->) to run.

Try It On Desmos!

This takes advantage of Desmos's implicit rounding with list ranges, which will always round both start and end numbers to the nearest integer. In this case, eeeln(eeeee) is mathematically equivalent to \$e^3\cdot5\approx100.42768\$ (\$e\approx2.71828\$ is Euler's number), which rounds down to 100.

If not acceptable, then here's an alternative version that might be more acceptable:

31 bytes

l=[0...eeeln(eeeee)]
(l,0)
${l}

Paste first two equations into Desmos, and label the list of points (l,0) as ${l}. Move the viewport to the right to view more numbers.

Try It On Desmos!

\$\endgroup\$
2
  • \$\begingroup\$ wouldn't it be valid to remove o=0? because then you just click add slider and the output is there. but idk, should prob ask on meta \$\endgroup\$
    – naffetS
    Commented May 12, 2022 at 4:01
  • \$\begingroup\$ @Steffan I considered that, but I'm not so sure if that's valid. I'm gonna ask on TNB and see what they say. \$\endgroup\$
    – Aiden Chow
    Commented May 12, 2022 at 4:25
6
\$\begingroup\$

APL (Dyalog), 19 bytes

⎕←0,⍳(+/⍳≢⍬⍬⍬⍬)*≢⍬⍬

Try it here!

≢⍬⍬⍬⍬ ⍝ This evaluates to 4
≢⍬⍬ ⍝ This evaluates to 2

⍳≢⍬⍬⍬⍬ ⍝ Evaluates to 1 2 3 4
(+/⍳≢⍬⍬⍬⍬) ⍝ Sums up previous list, 1+2+3+4 = 10
(+/⍳≢⍬⍬⍬⍬)*≢⍬⍬ ⍝ Exponentiates previous result by 2
⍳(+/⍳≢⍬⍬⍬⍬)*≢⍬⍬ ⍝ Generates 1 2 ... 100
0,⍳(+/⍳≢⍬⍬⍬⍬)*≢⍬⍬ ⍝ Appends 0 to front
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$
    – rydwolf
    Commented Nov 9, 2021 at 20:23
5
\$\begingroup\$

jq, 20 characters

range("e"|explode[])

Sample run:

bash-5.0$ jq -n 'range("e"|explode[])' | head
0
1
2
3
4
5
6
7
8
9

Try it online!

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

Lua (34 30 bytes)

for i=0,0xA*0xA do print(i)end
\$\endgroup\$
1
5
\$\begingroup\$

MATLAB, 13 bytes

0:double('d')

The ASCII code for lowercase d is 100, so convert to a double and go from 0 in intervals of 1 with ":"

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to the site, and nice first answer! \$\endgroup\$ Commented Feb 26, 2021 at 20:47
5
\$\begingroup\$

Wolfram Language (Mathematica), 20 bytes

The only real golfing opportunity for this question in the Wolfram language is to encode the number 100 with as few bytes as possible. There is only one real-valued constant symbol in the Wolfram language with a one byte name, namely E.

I thus looked for combinations of binary operations that were near 100. (E+E)^E is about 99.73, so adding E/E will give a suitable endpoint.

Range[0,(E+E)^E+E/E]

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can change E/E to 0! to save a byte. \$\endgroup\$
    – Axuary
    Commented Mar 2, 2021 at 4:16
5
\$\begingroup\$

Vim, 21 bytes

qqYP<C-x>qi0<esc><C-a>a00@q<esc>Yxx@0

Try it online!

Explanation

qq       q                             Record macro q:
  Y                                     Yank the current line
   P                                    Paste a copy of it on the line above
    <C-x>                               Decrement the number under the cursor
          i0<esc>                      Insert a 0
                 <C-a>                 Increment it to 1
                      a00@q<esc>       Append 00@q
                                Y      Yank this line (100@q)
                                 xx    Delete the @q part
                                   @0  Execute the yanked text as commands
                                       (100@q executes the q macro 100 times)
\$\endgroup\$
5
\$\begingroup\$

Rust, 41 40 39 35 bytes

Thanks to Redwolf for -1 byte, Unrelated String for -4

||for i in 0..b'e'{print!("{} ",i)}

Try it online!

 


39 bytes

||(0..b'e').all(|i|print!("{} ",i)==())

Try it online!


40 bytes

||(0..b'e').for_each(|i|print!("{} ",i))

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Welcome to Code Golf, and nice first answer! Can you save a byte by getting rid of that space before i in the print!? \$\endgroup\$
    – rydwolf
    Commented Oct 30, 2021 at 22:12
  • \$\begingroup\$ Would this work for 35? \$\endgroup\$ Commented Oct 30, 2021 at 23:58
5
\$\begingroup\$

C - 37 Bytes

i;f(){while(i<'e')printf("%d",i++);}

Ungolfed

i;
f()
{
    while(i < 'e')
        printf("%d", i++);
}

Explanation

Function to print numbers from 0 to 100 without digits. A global variable of type integer is created (so that it is automatically initialized to 0), the variable is incremented and printed 100 times through a loop which is executed while the variable is less than 'e' or 101 in ASCII.

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

PostScript: 11 bytes

00000000: 8800 8801 8864 7b3d 7d92 48              .....d{=}.H

A tokenized version of 0 1 100{=}for.

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

BBC BASIC, 29 19 bytes

I have revisited my first answer that I have posted more than 3 years ago and found out that the bytecount could be significantly reduced:

  • -4 bytes thanks to @Neil for the comment he left more than 3 years ago! (Substituting 7 bytes PRINT i with 3 bytes P.i. Note that the alias P. is majuscule.)
  • then again, -4 bytes by doing the analogous replacement of FOR i (5 bytes) with F.i (3 bytes) and NEXT with N.
  • -2 bytes: removal of two spaces
F.i=0TO&A*&A
P.i
N.

MY-BASIC, 32 bytes

for i=0 to 0xa*0xa
print i;
next

Try it online!

Edit: Thanks for upvoting! This has been my original golf but it has turned out that BBC BASIC has an even shorter syntax for hexadecimals as well as handy for golfing aliases :)

\$\endgroup\$
3
  • 5
    \$\begingroup\$ Welcome to the site, and nice first answer! \$\endgroup\$ Commented Feb 26, 2021 at 15:48
  • 5
    \$\begingroup\$ Doesn't BBC BASIC also have keyword abbreviations e.g. p.i for print i? \$\endgroup\$
    – Neil
    Commented Mar 8, 2021 at 0:36
  • 4
    \$\begingroup\$ that would normally be done with a question mark: ? i - but not in BBC BASIC \$\endgroup\$ Commented Mar 8, 2021 at 19:58
4
\$\begingroup\$

Powershell, 18 bytes

0..[byte][char]'d'
\$\endgroup\$
4
  • 1
    \$\begingroup\$ -5 bytes Try it online! \$\endgroup\$ Commented Feb 23, 2021 at 18:12
  • 1
    \$\begingroup\$ -9 bytes Try it online! \$\endgroup\$
    – Julian
    Commented 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
    Commented Feb 24, 2021 at 6:56
  • \$\begingroup\$ @Julian Wow, nice one!! \$\endgroup\$ Commented Feb 24, 2021 at 13:00
4
\$\begingroup\$

APL(Dyalog Unicode), 8 bytes SBCS

⍳⎕UCS'e'

Try it on APLgolf!

A tradfn submission which prints with space separator.

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

Julia 1.0, 19 bytes

println.(0:0xA*0xA)

Try it online!

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

bc, 17 bytes

for(;i<=A*A;i++)i

Try it online!

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

K (ngn/k), 6 bytes

!0+"e"

Try it online!

Uses 0+ to convert "e" to an integer, then takes the range from 0 up to, but not including, that value (101).

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

Rattle, 14 bytes

i+R`c0c0$[+i]~

Try it online!

Explanation

i                    prints the value at the top of the stack (0) 
 +                   adds 1 to the value on top of the stack (which was 0, is now 1.0)
  R`                 reformats the top of the stack with the arg ` (the value at the top of the stack).
                        since ` = 1, it reformats the top of the stack as the integer 1
    c0c0             concatenates the value in storage at the current pointer (=0) to the top of the 
                        stack twice, resulting in "100"
        $            swaps the value on top of the stack (100) with the value in storage at the 
                        current pointer (0)
         [ .... ]~   loop structure: loops ~ times, where ~ = value_in_storage_at_pointer = 100
            +        adds one to the value on top of the stack
             i       prints the top of the stack as an integer

Note: the above code is based on version 1.0.* of Rattle. With the newest update (1.1.0), the code could be shortened to the following snippet (12 bytes) because the addition operator will now keep the top of the stack the same type (in this case, an integer) if possible.

i+c0c0$[+i]~
\$\endgroup\$
4
\$\begingroup\$

Bash, 26 bytes

eval echo {$[x++]..${x}00}

Try it online!

(Previously)

Bash, 28 bytes

eval echo {$((++x))..${x}00}

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to Code Golf! Nice first answer. \$\endgroup\$
    – rydwolf
    Commented Feb 27, 2021 at 0:05
  • 1
    \$\begingroup\$ Your solution doesn't output 0, but fortunately the fix will cost you no extra character: just change the pre-increment to post-increment. While fixing it, you could change the $((..)) arithmetic evaluation to the deprecated but still functional old $[..] syntax to save 2 characters. (We have Tips for golfing in Bash in case you are looking for more tips.) \$\endgroup\$
    – manatwork
    Commented Feb 27, 2021 at 0:12
  • \$\begingroup\$ Thx for the tips @manatwork. Updated \$\endgroup\$ Commented Mar 2, 2021 at 3:05
4
\$\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\$ Commented Apr 11, 2021 at 2:27
4
\$\begingroup\$

Zig, 63 66 47 72 bytes

fn a()void{for(" "**'e')|_,i|{@import("std").debug.print("{d} ",.{i});}}

Try it online!

I've excluded the @import() boilerplate as it seems analogous to C's #include, which is excluded from other answers. If deemed necessary, I will add it back in.

Explanation

fn a() void {
    for (" " ** 'e') |_, i| {
        @import("std").debug.print("{d} ",.{i});
    }
}
  • fn a() void Declare a function which takes no parameters and returns nothing
  • for () |_, i| For every item in the array inside of (), iterate and capture the entree as _ (a throwaway variable) and the index as i
  • " " ** 'e' Take the string (strings are slices, or pointer-arrays which know their length) and repeat it 'e' (101) times
  • ** Requires a little bit more more explanation I think: In Zig, there is the concept of "comptime" (compile time) and runtime. ** is an operator which repeats any array literal or slice literal at comptime, because the resulting length is still known to the compiler.
  • @import("std").debug.print("",.{}); Print to STDERR (I believe that's valid for this question, right?), the first argument is the formatting string, and the second is an "anonymous sctruct"/tuple with a variable number of arguments in it (Zig doesn't have var-args).
  • "{d} " The format string. Zig denotes {} as the formatting characters, with d meaning a digit in this case.
\$\endgroup\$
0
4
\$\begingroup\$

Rust, 46 bytes

I did not see a rust solution, so here's my attempt:

||print!("{:?}",(0..b'e').collect::<Vec<_>>())

Try it online!

Thanks to @ovs for pointing out the closure variant.

The range (0..b'e') is collected into a vector (using the placeholder _, letting the compiler figure out the type) and printed using the debug formatter {:?}, which "dumps" the entire vector.

The range upper bound is exclusive, and is represented using the byte literal b'e', which is equivalent to an u8 integer number literal; in this case 101 (e's ASCII value).

\$\endgroup\$
2
  • \$\begingroup\$ How do you get 45 bytes? Your submission has to be either a full program (like the current code at 56 bytes) or a function/closure which can be 46 bytes \$\endgroup\$
    – ovs
    Commented Oct 29, 2021 at 15:55
  • \$\begingroup\$ I am sorry, I forgot to update the header after including fn main() { ... }. Will use the closure version. Thank you for pointing this out! \$\endgroup\$ Commented Oct 29, 2021 at 16:06
4
\$\begingroup\$

C, 53 bytes

int main(a,b){for(;a^'f';a++){printf("%d\n",a-!!a);}}

Try it online!

43 42 bytes

(Thanks to Jo King♦)

k;main(){for(;k^'e';)printf("%d ",k++);}

Try it online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to code golf, and nice first answer! Make sure to check out our tips for golfing in C to see if there's any way for you to shorten your code. \$\endgroup\$ Commented Oct 29, 2021 at 13:37
4
\$\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\$

Your Answer

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