57
\$\begingroup\$

Print 0 to 100 without using characters 1,2,3,4,5,6,7,8,9 in your code.

Seperator of numbers can be comma, whitespace or newline.

Shortest code wins.

\$\endgroup\$
7
  • 14
    \$\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
  • 2
    \$\begingroup\$ I thought "do X without Y" questions weren't allowed anymore. \$\endgroup\$
    – Purple P
    Feb 24, 2021 at 3:34
  • 2
    \$\begingroup\$ @PurpleP They're allowed, but discouraged. Interesting ones are fine. \$\endgroup\$ Feb 25, 2021 at 0:06
  • 12
    \$\begingroup\$ Is there a requirement to stop printing at 100? \$\endgroup\$
    – spuck
    Feb 25, 2021 at 16:44
  • \$\begingroup\$ Can we do it in reverse order? \$\endgroup\$
    – Dion
    Oct 16, 2021 at 9:51

137 Answers 137

2
\$\begingroup\$

Excel, 23 22 23 bytes

=SEQUENCE(CODE("e"),,0)

Spreadsheet

Invalid Change

=SEQUENCE(CODE("e"))-1
\$\endgroup\$
3
  • 1
    \$\begingroup\$ There's a forbidden 1 in your code. The original one is fine. \$\endgroup\$
    – Dorian
    Jul 8, 2021 at 9:50
  • 2
    \$\begingroup\$ @Dorian, This is a fine example of me thinking I'm clever when I am being stupid. Thanks for keeping me honest. \$\endgroup\$
    – Axuary
    Jul 8, 2021 at 15:32
  • \$\begingroup\$ How about =SEQUENCE(ROW(),,0) in A101? \$\endgroup\$ Oct 25, 2021 at 18:57
2
\$\begingroup\$

Vim, 16 bytes

i0<Esc><C-a>s<C-r>=r    <C-r>"0<C-r>")

Try it online!

Explanation:

i0<Esc>                                 # Insert `0`
       <C-a>                            # Increment
            s                           # Delete into register " and Insert
             <C-r>=                     # Start expression
                   r                    # Tab-autocomplete `range(`
                        <C-r>"          # 1
                              0         # 0
                               <C-r>"   # 1
                                     )  # Full expression is `range(101)`
                                        # Insert the range [0..101)

Alternatively (and more interesting, imo):

Vim, 18 bytes

iYp<C-v><C-a>0<Esc>d^@=!0
00@-

Try it online!

Explanation:

iYp<C-v><C-a>0<Esc>        # Insert `Yp<C-a>0`
                   d^      # Delete `Yp<C-a>`
  @-                       # Execute `Yp<C-a>`... times
                     @=!0  #                  1
00                         #                   00
\$\endgroup\$
2
\$\begingroup\$

Java 106 bytes

class p {public static void main(String[] args){int i='A'/'A';while(i<=(int)'d')System.out.println(i++);}}}}

TIO

\$\endgroup\$
4
  • \$\begingroup\$ can't say about size but yeah logic sorta be cool. :) \$\endgroup\$
    – Ha'Penny
    Oct 22, 2021 at 13:12
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice first answer! Don't worry about the size, as long as there's an attempt to golf it as much as you can, pretty much any serious answer is accepted here. :) After all, we allow answers in Unary, which typically has answers in the hundreds of thousands of bytes or more! \$\endgroup\$ Oct 22, 2021 at 13:25
  • \$\begingroup\$ You can check out the tips for golfing in Java if you want, but this looks pretty good! I edited it a tiny bit to use code block formatting. \$\endgroup\$ Oct 22, 2021 at 13:29
  • 1
    \$\begingroup\$ 94 bytes \$\endgroup\$
    – ceilingcat
    Oct 24, 2021 at 6:49
2
\$\begingroup\$

Oracle SQL, 56 bytes

select level-cos(0)from dual connect by level<ascii('f')

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ instead of -cos(0), I would imagine you could write +~0 \$\endgroup\$ May 12 at 10:34
2
\$\begingroup\$

JavaScript (V8), 30 bytes

for(i=0;+!print(i)+'00'-i++;);

Try it online!

Jo king saves more bytes that I can count :)

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

!@#$%^&*()_+, 13 bytes

e($!#^$_^_
@)

Try it online!

Explaination:

e($!#^$_^_
@)

e            Pushes 101 onto the stack
 (           While
  $          Swap
   !#        Output number without popping and newline
     ^       Top of stack = Top of stack + 1
      $      Swap
       _^_   Top of stack = Top of stack - 1
<newline>    Push 10
@            Output top of stack as ASCII and pop
 )           Close while
\$\endgroup\$
2
  • \$\begingroup\$ 11 \$\endgroup\$
    – null
    Apr 17 at 4:32
  • \$\begingroup\$ (Of course, replacing _^_ with * is 11 as well) \$\endgroup\$
    – null
    Apr 17 at 4:34
2
\$\begingroup\$

Labyrinth, 18 bytes

0) @
0 \(
)#":
 (!

Try it online!

Push 101 () is increment and 0 is "append zero" command), and run "print stack height - 1, dup, decrement" until the top becomes zero.

Labyrinth, 19 bytes

0)
0
)}:!
 " \
@({)

Try it online!

Keep track of two values a=0 and b=101, print a and increment and decrement b until b becomes zero.

\$\endgroup\$
2
  • \$\begingroup\$ 17 bytes and alternative. There's probably another byte to be saved? \$\endgroup\$
    – Jo King
    Oct 29, 2021 at 9:44
  • \$\begingroup\$ Ah, 16 bytes with termination by division by zero \$\endgroup\$
    – Jo King
    Oct 29, 2021 at 9:59
2
\$\begingroup\$

Pure Bash, 34 + 1 = 35 bytes

Filename must be x; this is for extra one byte.

echo $[x++]
a=x
((x>${#a}00))||. x

Try it online!

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

Lua (29 bytes)

for i=0,0xA..0 do print(i)end
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ Apr 16 at 3:18
2
\$\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\$
1
\$\begingroup\$

VBScript, 33 bytes

for i=0 to asc("d")
msgbox i
Next

Competitive answer in VBScript!

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

Javascript (Browser), 53 46 37 33 bytes

for(n=0;++n<+atob`MTAx`;)alert(n)

-15 bytes thanks to @EliteDaMyth

\$\endgroup\$
7
  • 1
    \$\begingroup\$ change the parseInt() to +atob`MTAx` for 11 bytes \$\endgroup\$
    – user100752
    Feb 23, 2021 at 15:58
  • \$\begingroup\$ @EliteDaMyth thanks for that! \$\endgroup\$
    – Wasif
    Feb 23, 2021 at 16:00
  • 1
    \$\begingroup\$ also @Wasif you dont need the curly braces after the for loop. and you can change the way the for loop works, by incrementing, while checking, i.e. for(n=0;++n<+atob`MTAx`;)alert(n) this is 33 bytes \$\endgroup\$
    – user100752
    Feb 23, 2021 at 16:02
  • \$\begingroup\$ @EliteDaMyth thanks again! \$\endgroup\$
    – Wasif
    Feb 23, 2021 at 16:04
  • 4
    \$\begingroup\$ you don't need the + in front of atob`MTAx`; \$\endgroup\$
    – Wezl oOvOo
    Feb 23, 2021 at 17:15
1
\$\begingroup\$

J, 12 bytes

a.i.@i.'e'"_

Try it online!

\$\endgroup\$
7
  • \$\begingroup\$ i.a.i.'e' for 9 works fine for me... \$\endgroup\$ Feb 27, 2021 at 20:58
  • \$\begingroup\$ i.'e' returns 101, \$\endgroup\$ Feb 27, 2021 at 21:05
  • \$\begingroup\$ Sadly that’s a snippet hence not legal according to site rules \$\endgroup\$
    – Jonah
    Feb 27, 2021 at 21:51
  • \$\begingroup\$ For more, see this meta discussion \$\endgroup\$
    – Jonah
    Feb 27, 2021 at 22:05
  • \$\begingroup\$ Hi Jonah could you please specify the difference between a snippet and a function, particularly in regard to J \$\endgroup\$ Mar 28 at 18:37
1
\$\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\$
1
\$\begingroup\$

C# (.NET Core), 56 bytes

for(int i=0;i<=(0xb0e-0xaaa);i++){Console.WriteLine(i);}

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ -1 byte by moving the i++ into Console.WriteLine(). Try it online! \$\endgroup\$ Feb 23, 2021 at 18:22
  • \$\begingroup\$ 52 bytes by getting rid of the curly braces and switching to < rather than <=, along with the byte save from my last comment Try it online! \$\endgroup\$ Feb 23, 2021 at 18:33
  • \$\begingroup\$ Also, char has an implicit conversion to int, so you can replace the magic hex codes with 'e' for 42 bytes Try it online!, though upon looking it seems the C answer by Noodle got to that idea first. \$\endgroup\$ Feb 23, 2021 at 18:37
1
\$\begingroup\$

Nim, 26 bytes

for i in 0..'d'.ord:echo i

Try it online!

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

Charcoal, 7 5 bytes

IE℅eι

Try it online! Link is to verbose version of code. Explanation:

   e    Literal string `e`
  ℅     ASCII code i.e. 101
 E      Map over implicit range
    ι   Current value
I       Cast to string
        Implicitly print
\$\endgroup\$
1
\$\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\$
1
\$\begingroup\$

Tcl, 46 bytes

set i 0
while \$i<[incr u]0$u {puts $i
incr i}

Try it online!

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

SimpleTemplate 0.84, 45 bytes

This was fun, but quite difficult.

The code outputs all numbers from 0 to 100, with a trailing newline:

{@setC 0}{@for_ from"   "to"m"}{@echolC}{@incC}

Due to bugs in the compiler, the tab character (inside {@for_ from" "to"m"}) MUST be a real tab.


Ungolfed

This version should be easier to read, despite being functionally the same:

{@set counter 0}
{@for i from "  " to "m"}
    {@echo counter, EOL}
    {@inc counter}
{@/}

Closing the {@for [...]} is optional, but left here for the cleanest code possible.


You can try this on https://ideone.com/tLsDFn

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

Stax, 5 bytes

AJ^rJ

Run and debug it

AJ^   10 squared plus 1 (101)
   r  range from 0..n-1
    J join with spaces
\$\endgroup\$
1
\$\begingroup\$

Elixir, 42 28 bytes

(?b-?a)..?d|>Enum.join("\n")

Try it online!

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

Japt, 2 bytes

Try it online!

This outputs a list of numbers from 0 to 100 separated by commas.

How it works

Lò
L   -Number 100 
 ò  -Creates an inclusive range from 0 to L, and return it in the output
\$\endgroup\$
1
\$\begingroup\$

C++, 77 Bytes

#import<iostream>
main(){for(int i=0;i<=int('d');++i)  std::cout<<i<<" ";}

Here, I've used the ASCII value and ran the loop and printed the value. Simple!

\$\endgroup\$
1
  • \$\begingroup\$ This can definitely be golfed a bit, like by removing unnecessary whitespace and newlines. Make sure to read our tips questions if you want some hints! \$\endgroup\$ Mar 8, 2021 at 18:14
1
\$\begingroup\$

TeX, 57 bytes

\newcount~\loop\advance~`^^A\the~ \ifnum~<`^^%\repeat\bye

Makes uses of these two tricks:

  • \$\rm\TeX\$'s preprocessor runs through the code and replaces any instance of two consecutive superscript (category code 7) characters followed by a character token, and adds/subtracts 64 from its ascii code, hence ^^A becomes NUL.
  • \$\rm\TeX\$ has a `backtick notation' of inputting numbers that reads the following character's ascii code instead.
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 8/11 bytes

'e'{}/,`

Try it online! - 8 Bytes

Makes an array of values of e (101) elements, starting at 0, then formats with spaces. The format also has brackets at either end of the output, so it may not be valid. If not, they can be removed with 3 more bytes:

'e'{}/,' '*

Try it online! - 11 Bytes

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

V (vim), 30 bytes

i00<esc><C-a>hxpi0<esc>0"aDi0<esc>qqYp<C-a>q@a@qdd

Try it online!

can definitely be improved.

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

K (oK), 4 bytes

Solution:

!"e"

Try it online!

Explanation:

Scrolling through the other solutions tells me I wasn't as novel as I hoped when I came up with this.

!"e" / the solution
 "e" / ASCII 101
!    / til (i.e. range 0..n-1
\$\endgroup\$
1
\$\begingroup\$

Barrel, 9 bytes

#d(n+¶)n

Explanation:

#        // as many times as...
 d       // ...the ASCII value of 'd' (100)...
  (   )  // Create a single of instruction for the loop
   n     // print the accumulator of a number
    +    // increase the accumulator
     ¶   // print a newline
       n // print the final number

The final n is necessary because the loop only prints the numbers 0 to 99.

I could've shaved off 2 bytes by doing #e(n+¶, which would have used the ASCII value of 'e' (101) and also utilized the self-closing properties of the () instruction, but I had already assigned e to be the value of the mathematical constant \$e\$.

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

Pxem, 21 20 bytes (filename) + 0 bytes (content) = 23 21 20 bytes, requires unprintable character.

  • Filename (escaped unprintable): \001.r.-.z.c.n,.o\001.+.ce.a
  • Content: empty.

Try it online!

With comments

XX.z
# push 1; push int(rand()*pop)
## NOTE rand() outputs 0<=n<1
## NOTE assuming NUL cannot be used for filename
.a\001.rXX.z
# while size<2 || pop!=pop; do
.a.zXX.z
  # dup; print pop; push comma; putc pop
  .a.c.n,.oXX.z
  # push 1; push pop+pop; dup; push 101
  .a\001.+.ce
# done
.a.a

Pxem, 3 bytes (filename) + 20 bytes (content) = 23 bytes, requires unprintable character.

  • Filename: e.e
  • Content (some unprintables are escaped): .c.w\001.-.e.+.n .o.d.a

With comment

e.eXX.z # push 101; call content
.a
XX.z
# dup; while pop!=0; do
.a.c.wXX.z
  # push 1; push abs(pop-pop); call content (* result of final stack will be pushed to original *)
  .a\001.-.eXX.z
  # push pop+pop; print pop; push space; print pop; return
  .a.+.n .o.dXX.z
# done; (* implicit return *)
.a.a

Try it online! (with pxem.posixism)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy