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

2
\$\begingroup\$

Rust, 49 bytes

(0..'e' as usize).for_each(|x| print!("{} ",x));

  • 'e' as usize casts literal 'e' to its Unicode number
  • Creates a Range and then for each of the elements in the range, prints the elements.
\$\endgroup\$
1
  • \$\begingroup\$ Oops, totally did not see that! @WheatWizard. Changed u32 to usize. \$\endgroup\$
    – StaticESC
    Commented Feb 13, 2023 at 4:36
2
\$\begingroup\$

Itr, 10 bytes

'eMºM»£'
¥

online interpreter

4 bytes ('eMº) if surrounding the output with brackets is allowed

Explanation

'e          ; the literal 'e' (ascii 101)
  Mº        ; unwrap string,and convert to 0-based range
    M»      ; for every element of the range
      £     ; print the element
       ' 
        ¥   ; print a newline
\$\endgroup\$
2
\$\begingroup\$

Backhand, 13 bytes

:_@v^O-
e]'}:

Try it online!

I don't feel like this is optimal, but I can't figure out how to do better than that.

The literal newline is just a command that prints a newline, so I replaced it with n so that the explanation is hopefully easier to follow.

The entire program is a single loop that mostly operates with step size 2 (to minimize unused spaces).

:_@v^O-ne]'}:   initial step size is 3
                stack contains the current loop counter `n`, or empty (implicit 0)
:               [n n] duplicate
   v            reduce step size to 2
     O          [n] output as number
       n        output literal newline
         ]      [n+1] increment
           }    bump the IP once to the right, so it can run
                different instructions on the way back
            :   [n+1 n+1] duplicate
        e '     [n+1 n+1 101] push 'e' = 101
      -         [n+1 n-100] subtract
    ^           increase step size to 3
 _              if the top is 0, bump to the right, otherwise bump to the left
  @             right: halt
                left: return to the beginning of the loop
\$\endgroup\$
1
  • 1
    \$\begingroup\$ 12 bytes: ]Eb:d*O'j\n:@ \$\endgroup\$
    – Jo King
    Commented Sep 20, 2023 at 10:26
2
\$\begingroup\$

Vyxal SH, 7 bitsv2, 0.875 bytes

ʀ

Try it Online!

Another flag cocktail.

Bitstring

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

Morsecco 59 60 bytes

Avoiding digits is not really challenging in a language without digits, but I found it interesting which strategy would give the shortest code.

The straight forward loop takes 66 bytes:

. . -- - - - -.- -. --- . - .- - - . .--..-.- .- --.. --. - .- --.
  • . . to Enter 0
  • -- - to Mark the current program position
  • - - -.- -. dup and Konvert to Number
  • --- to Output
  • . - .- to Enter 1 and Add
  • - - . .--..-.- .- dup, Enter -101 and Add
  • --.. --. to Zeroskip until next --.
  • - .- --. drop the unused difference and Go to marked position

Two more bytes can be saved by using an empty token as target for the Zeroskip (note the essential trailing space!): . . -- - - - -.- -. --- . - .- - - . .--..-.- .- --.. - .- --. (64 bytes)

Counting down is usually cheaper, but here we need to concatenate the numbers to a string to show them in the correct order (70 bytes):

.    . --..-.- -- - . .- .- - - - .. -.-. .. - . --..  --.  -.- -. ---
  • . to Enter an empty cell on the stack as the string to build
  • . --..-.- to Enter 101 so we can start the loop by decrementing
  • -- - to Mark the start of the loop
  • . .- .- decrement by Adding -1
  • - - - .. -.-. .. dup, rot the string to the top and Concatenate the cells with a space in between
  • - . --.. --. swap to get the index to the top and do a Zeroskip the the Go command that closes the loop
  • -.- -. --- to Konvert the whole string to Number and Output

An unusual trick takes us down to 61 bytes: Counting up from -101 to 0 and directly outputting the index+101:

. .--..-.- -- - - - . --..-.- .- -.- -. --- . - .- --..  --. 

I found no way to mitigate Entering the 101 twice without wasting the bytes for stack juggling.

Finally, the best solution with 60 bytes turned out to be defining a recursive command (I used the undefined command -.):

.   - - --.. -. . .- .- -. -.- -. ---  . -. .-- . --..-.. -.
  • . [command] . -. .-- to Enter the command and Write it to address -.
  • . --..-.. -. to Enter 100 and call the new command
  • The command itself is
    • - - --.. -. dup and Zeroskip to the self-calling -.
    • . .- .- decrement by Adding -1
    • -. call itself with the decremented value
    • -.- -. --- to Konvert to Number and Output. As this is done after calling itself, it is done first for the 0 case, to resorting is done automatically

eXecuting the command directly from the stack . --..-.. . - - --.. -..- . .- .- . .- -..- -.- -. --- -..- save nine bytes for saving the command, but wastes three time the two bytes that -..- is longer than -. and five more bytes for placing .- on the stack to eXecute Again, ending in 62 bytes.

I hope this illustrates why I like morsecco as a golfing language: There are many ways to do something and a lot of tricks to discover. The pure score is not impressing, but considering that you could pack 5 characters into one byte (3^5 = 243 < 256), 12 true bytes even beat some golfing languages!

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

VBScript, 33 bytes

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

Competitive answer in VBScript!

\$\endgroup\$
1
  • \$\begingroup\$ I noticed your answer is similar to my answer \$\endgroup\$
    – Eric Xue
    Commented Jul 10, 2022 at 16:01
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
    Commented Feb 23, 2021 at 15:58
  • \$\begingroup\$ @EliteDaMyth thanks for that! \$\endgroup\$
    – Wasif
    Commented 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
    Commented Feb 23, 2021 at 16:02
  • \$\begingroup\$ @EliteDaMyth thanks again! \$\endgroup\$
    – Wasif
    Commented Feb 23, 2021 at 16:04
  • 4
    \$\begingroup\$ you don't need the + in front of atob`MTAx`; \$\endgroup\$
    – Wezl
    Commented 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\$ Commented Feb 27, 2021 at 20:58
  • \$\begingroup\$ i.'e' returns 101, \$\endgroup\$ Commented Feb 27, 2021 at 21:05
  • \$\begingroup\$ Sadly that’s a snippet hence not legal according to site rules \$\endgroup\$
    – Jonah
    Commented Feb 27, 2021 at 21:51
  • \$\begingroup\$ For more, see this meta discussion \$\endgroup\$
    – Jonah
    Commented 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\$ Commented Mar 28, 2022 at 18:37
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\$ Commented Feb 23, 2021 at 18:22
  • 1
    \$\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\$ Commented 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\$ Commented 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\$

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\$
    – rydwolf
    Commented 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\$

///, 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
    Commented Feb 28, 2021 at 17:39
  • \$\begingroup\$ @manatwork ill work on that ;) \$\endgroup\$ Commented Mar 1, 2021 at 15:26
1
\$\begingroup\$

Python 3; 46 Bytes

x=True;a=x+x;b=a*a+x;print(*range(a*a*b*b+x))
\$\endgroup\$
0
1
\$\begingroup\$

ErrLess, 23 25 17 bytes

Thanks to Jo King for saving 8 bytes

0Z@#@'d<l+[.a?l-z

Explanation

0   { Add zero to the stack: (x) }
Z   { Set a "checkpoint" to jump back to later }
@#@ { Output as number & Duplicate: (x x) }
'd< { x < d - true -> -1; false -> 0? (x x<d) }
l   { Get the length of the top element (-1 for integers): (x x<d -1) }
+   { Add: (x [-2 or -1]) }
[   { Skip backwards that many instructions (skip forwards 1 or 2): (x) }
.   { Halt }
a?  { Push 10 and print (print newline) }
l-  { Increment: (x--1) }
z   { Go to "checkpoint" }

Try it online!

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

APOL, 11 bytes

f(ô p(∈));ô

I would've used instead of f, but the rules state that you have to include 0 so the fastest route was to just print 0-99 and slap 100 at the end.

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

Kotlin, 48 46 bytes

('P'..'´').joinToString(","){""+it.minus('P')}

Saving two bytes by using other chars from the ascii table that only takes one instead of two bytes.

Try it online!

48 bytes version

('\n'..'n').joinToString(","){""+it.minus('\n')}

Using the ascii table to get those numbers.

Try it online!


When brackets are allowed at the start and end then this is smaller:

29 bytes

('P'..'´').map{it.minus('P')}

Try it online!

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

><>, 18 bytes

0::naoaa*(?!;ba-+!

Try it online!

Explanation

0                   Initialize stack with 0
 ::                 Duplicate the top of the stack twice, once for printing and once for comparing
   n                Pop the top of the stack, and print as a number
    ao              Push 0xa to the stack, and pop it to print as a char
      aa*           Push 100 (10*10) onto the stack
         (          Pop the top two values of the stack, and compare if one is less than the other
          ?!;       If not, halt execution, else...
             ba-    Push 1 (11-10) onto the stack
                +   Add the top two values on the stack
                 !  Skip the next instruction
                    IP Moves back to the 0
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 6 bytes

'e'),`

Try it online!

Similar to the other GolfScript answer, the output has brackets, which can be removed with the following 7-byte answer:

GolfScript, 7 bytes

'e'),n*

Try it online!

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

Thunno, \$ 4 \log_{256}(96) \approx \$ 3.29 bytes

'eOR

Attempt This Online!

Outputs [[0, 1, 2, ..., 99 100]].

Thunno j, \$ 6 \log_{256}(96) \approx \$ 4.94 bytes

'eORAJ

Attempt This Online!

Outputs 0 1 2 ... 99 100.

Explanation

'e      # Push 'e'
  O     # Get the ordinal, 101
        # (this is wrapped in a list)
   R    # Push range(0, 101)
        # (again wrapped in a list)
    AJ  # Get the first item of the list
        # j flag joins by spaces
\$\endgroup\$

Your Answer

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