40
\$\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\$
6
  • 11
    \$\begingroup\$ Many tricks are made possible by allowing 0. Which is what makes this challenge interesting, IMO. \$\endgroup\$
    – Arnauld
    Feb 23 at 17:08
  • 2
    \$\begingroup\$ I thought "do X without Y" questions weren't allowed anymore. \$\endgroup\$
    – Purple P
    Feb 24 at 3:34
  • 1
    \$\begingroup\$ @PurpleP They're allowed, but discouraged. Interesting ones are fine. \$\endgroup\$ Feb 25 at 0:06
  • 7
    \$\begingroup\$ Is there a requirement to stop printing at 100? \$\endgroup\$
    – spuck
    Feb 25 at 16:44
  • \$\begingroup\$ Can we do it in reverse order? \$\endgroup\$
    – Dion
    2 days ago

111 Answers 111

1 2 3
4
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\$

Batch 100 bytes

run from cmd.exe's command line using: echo(hexhundred|cmd /V:on

filename: hexhundred.bat

@Set /A s=0xa*0xa&@Echo(0
@For /l %%i in ()Do @If !a! LSS !s! @(Set/A a+=0xb-0xa&echo(!a!)Else Exit

uses an infinite for /l loop and hex values to increment by 0xb-0xa [11-10=1] loop is broken when 0xa*0xa [10x10=100] is reached

\$\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\$
1
\$\begingroup\$

Pyth, 4 bytes

UC\e

Try it online!
Surprised myself by topping the previous Pyth's top score of 5 bytes. Creates a range from 0-101 (char code of 'e' = 101)

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

Risky, 3 2 bytes

0:--

Try it online!

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

///, 231 166 bytes

/\\\\\/\//\\\/\/\/\/\/\/\/\/\/\/\/\///\/\\\/\/\//\\\/\
\/\\\\\\\/\
\\\/\/\\\\\\\/\\\/\\\/\\\\\\\\\\\/\/\/\\\/\\\/\\\\\\\\\\\/\/\\\\\\\/\
\\\/\/\/\\\/\///\\\\\\\\\\\//

Try it online!

This was really fun to make. Sadly, there is a single newline. Using a backslash instead breaks everything, and I don't really want to figure out where everything is and fix it.

Update: I remade it from the ground up, it is now much smaller, and works with only slashes. Unfortunately, the challenge specifies commas and whitespace seperators only, so only slashes is not allowed.

Slashes only:

///, 182 bytes

/\\\\\/\//\\\/\/\/\/\/\/\/\/\/\/\/\///\/\\\/\/\//\\\/\\\\\/\\\\\\\/\\\\\\\\\\\/\/\\\\\\\/\\\/\\\/\\\\\\\\\\\/\/\/\\\/\\\/\\\\\\\\\\\/\/\\\\\\\/\\\\\\\\\\\/\/\/\\\/\//\\/\\\\\\\\\\\//

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Looks like the output starts with 1, while should start with 0. \$\endgroup\$
    – manatwork
    Feb 28 at 17:39
  • \$\begingroup\$ @manatwork ill work on that ;) \$\endgroup\$ Mar 1 at 15:26
1
\$\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\$
1
\$\begingroup\$

AWK, 35 bytes

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

Try it online!

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

C++ gcc, 36 bytes

Try it online!

main(){for(;_<'e';)cout<<_++<<'\n';}

Explanation : I globally initialized varible _ so its initial value is 0, now ascii value of e is 101 so I ran the loop till my variable _ is less than 'e', instead of incrementing it inside the for loop I used post increment while printing to save 1 byte

edit: I misread the question and thought 0 is also not allowed :)

\$\endgroup\$
4
  • \$\begingroup\$ Could you explain the code please? \$\endgroup\$
    – Anush
    Oct 14 at 16:41
  • 1
    \$\begingroup\$ @Anush I have added explanation, hope it helps. \$\endgroup\$ Oct 14 at 16:51
  • \$\begingroup\$ Do you know what this would be in C? \$\endgroup\$
    – Anush
    Oct 14 at 20:46
  • \$\begingroup\$ You'll have to include the _ declaration with the code I'm afraid, since it won't work without it. I'm not familiar with C++ golfing, but I believe you'd have to include the rest of the boilerplate, since this is a full program \$\endgroup\$
    – Jo King
    2 days ago
1
\$\begingroup\$

GFortran, 29 bytes

try it online!

print*,(j,j=0,ichar('d'))
end

Similar to this.

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

Python 3, 33 bytes

for x in range(ord("e")):print(x)
\$\endgroup\$
0
\$\begingroup\$

Elixir, 26 bytes

for x<-0..?d,do: IO.puts x

Try it online!

\$\endgroup\$
0
\$\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\$
0
\$\begingroup\$

Batch, 56 bytes

@set/ax=0xb-0xa
@for /l %%b in (0,%x%,%x%00)do @echo %%b

-61 bytes for @Neil

\$\endgroup\$
6
  • 1
    \$\begingroup\$ You can just use set/ax=0xb-0xa to set x etc. \$\endgroup\$
    – Neil
    Feb 23 at 17:01
  • \$\begingroup\$ @Neil edited thanks \$\endgroup\$
    – wasif
    Feb 23 at 17:53
  • \$\begingroup\$ Actually you don't need y at all, just use %x%00 in its place. \$\endgroup\$
    – Neil
    Feb 23 at 17:54
  • \$\begingroup\$ Also, some general Batch golfing tips: you don't need the space in set/a or )do, and you can remove the @echo off and use @set, @for and @echo instead. \$\endgroup\$
    – Neil
    Feb 23 at 17:56
  • \$\begingroup\$ @Neil thanks! for that \$\endgroup\$
    – wasif
    Feb 23 at 17:58
0
\$\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 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 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 at 18:37
0
\$\begingroup\$

Red, 36 bytes

repeat n 0 +#"e"[print n +#"a"-#"b"]

Try it online!

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

C (gcc), 40 39 bytes

Saved a byte thanks to att!!!

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

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ 39 bytes \$\endgroup\$
    – att
    Feb 23 at 18:31
  • \$\begingroup\$ @att Nice one - thanks! :D \$\endgroup\$
    – Noodle9
    Feb 23 at 18:50
0
\$\begingroup\$

Nim, 26 bytes

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

Try it online!

\$\endgroup\$
1 2 3
4

Your Answer

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