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

1 2 3 4 5
6
1
\$\begingroup\$

Pyt, 7 bytes

00⁺⁺ᴇŘÁ

Try it online!

0           push 0
 0⁺⁺        push 0 and increment twice
    ᴇ       10^2
     Ř      push Řange (0,1,...,100)
      Á     push contents of Árray to stack; implicit print
\$\endgroup\$
1
\$\begingroup\$

Hebigo, 25 bytes

print: : :* range:ord:"e"
\$\endgroup\$
1
\$\begingroup\$

Pascal, 94 B

This full program complies with ISO standards 7185 (“Standard Pascal”) and 10206 (“Extended Pascal”). The statement write(integerExpression) is automatically expanded to write(integerExpression:integerDefaultMinimumWidth). The value of integerDefaultMinimumWidth is implementation-defined. The following code requires that integerDefaultMinimumWidth ≥ 4 to ensure adequate number separation.

program p(output);var n:integer;begin n:=succ(succ(0));for n:=0 to sqr(n*n*n+n)do write(n)end.

70 B: Provided that the character 'd' has an (implementation-defined) ordinal value of 100 (like in ASCII) you can write:

program p(output);var c:char;begin for c:=''to'd'do write(ord(c))end.

Note, the first character literal '' is chr(0). It is assumed that '' does not denote an end-of-line character. Pascal specifically bans multi-line string/char literals.

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

6510 Assembler for C64 (159 Bytes)

*=$c000
a=0^0
b=a+a
    ldx #0
    txa
    dex
    stx r+b
    stx w+b
    stx z+b
    stx p+b
    stx o+b
    stx y+b
    sec
    sbc 0
    tay
    iny
    sty r+a
    sty w+a
    sty z+a
    sty p+a
    sty o+a
    sty y+a
    lda 0
    lsr
    lsr
    tay
    dey
    sty s+a
    ldy 0
    iny
    sty q+a
    sty t+a
    sty o-a
    tya
    iny
    sty p-a
    clc
    adc s+a
    sta x+a
    lda s+a
    clc
    adc s+a
    adc s+a
    tay
    iny
    iny
    sty z-a 
    lda 0
    asl
    tay
    iny
    iny
    iny
    iny
    iny
    iny
    sty c+a   
    ldx #0
d   txa
q   ldy #0
    sec
s   sbc #0
    bcc t
    iny
    bne s
t   cpy #0
    beq u
    sta v+1
    tya
r   jsr 0
v   lda #0
u   clc
x   adc #0
w   jsr 0
    lda #0
z   jsr 0
    inx
c   cpx #0
    bne d
    lda #0
p   jsr 0
    lda #0
o   jsr 0
y   jmp 0

\$\endgroup\$
1
  • \$\begingroup\$ Very good entry. \$\endgroup\$ Commented Nov 17, 2023 at 16:26
1
\$\begingroup\$

COMMODORE 64 = 34 Bytes

With Commodore BASIC keyword abbreviations:

0?B:B=B-(A=.):IFB<aS(" ")*πgO

Or without the keyword abbreviations:

0 PRINTB:B=B-(A=.):IFB<ASC(" ")*πGOTO
\$\endgroup\$
1
  • \$\begingroup\$ I tidied up this entry to show the symbolic listings a bit better, and linked to the C64 Wiki for an explanation of Commodore BASIC Keyword Abbreviations. \$\endgroup\$ Commented Nov 17, 2023 at 16:25
1
\$\begingroup\$

Hexagony, 19 bytes

&!)')$0<.0.>.;/-{@_

Try it online! or on hexagony.net

In hexagon layout:

   & ! )
  ' ) $ 0
 < . 0 . >
  . ; / -
   { @ _

Completely ungolfed:

    & ! ) {
   . . . . .
  . . . . . .
 & ) 0 ; 0 ' -
  . . . . . .
   . . . . .
    @ . . .

The solution works by maintaining an invariant at the beginning of each iteration that the current memory cell zero or negative (current number - 100 on all iterations except the first one) and the cell to the left is the current number.

Solution's memory

  • &! copies current number from the cell to the left (due to the memory invarant) and prints it

  • ) increments current cell, so it will be current number for the next iteration

  • { moves to the memory cell to the left, pointing towards two cells with zeros

  • & copies zero from one of those cells into current cell

  • )0; sets current cell value to 10 (ascii code for newline) and prints it

  • 0 sets current cell value to 100 = 10 * 10 + 0

  • ' moves to the memory cell to the back right without turning memory pointer around, so now it points towards next number to the left and 100 to the right.

  • - computes next number - 100

  • Finally pointer leaves the right corner while moving to the right, so it wraps around to the top row if next number - 100 is zero or negative, or to the bottom row otherwise where it terminates at @.

Golfed solution fits everything into a hexagon with side 3 by taking advantage of changing instruction pointer's direction, grid wrapping and idempotency of - operator.

I don't know if a solution with side 2 (7 cells) is possible, but this solutions uses 9 different operators without counting the ones that control direction, so it definitely won't fit. A more optimal side 3 solution might also be possible.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf! This is an excellent answer, with a great explanation of the workings. I hope to see more from you in future! \$\endgroup\$ Commented Nov 19, 2023 at 12:48
1
\$\begingroup\$

Setanta, 57 43 bytes

−14 bytes using Uiua’s approach.

p:=pi@mata le i idir(0,p*p*p*p+p)scriobh(i)

try-setanta.ie link

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

UiuaSBCS, 8 6 bytes

⇡-@J@¯

Try it here!

Creates an array of all the numbers less than the difference of J and ¯ in codepoints, or 101.

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

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
    Commented Feb 23, 2021 at 17:01
  • \$\begingroup\$ @Neil edited thanks \$\endgroup\$
    – Wasif
    Commented Feb 23, 2021 at 17:53
  • \$\begingroup\$ Actually you don't need y at all, just use %x%00 in its place. \$\endgroup\$
    – Neil
    Commented Feb 23, 2021 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
    Commented Feb 23, 2021 at 17:56
  • \$\begingroup\$ @Neil thanks! for that \$\endgroup\$
    – Wasif
    Commented Feb 23, 2021 at 17:58
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
    Commented Feb 23, 2021 at 18:31
  • \$\begingroup\$ @att Nice one - thanks! :D \$\endgroup\$
    – Noodle9
    Commented Feb 23, 2021 at 18:50
0
\$\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\$
    – user7467
    Commented Oct 14, 2021 at 16:41
  • 1
    \$\begingroup\$ @Anush I have added explanation, hope it helps. \$\endgroup\$
    – cheems
    Commented Oct 14, 2021 at 16:51
  • \$\begingroup\$ Do you know what this would be in C? \$\endgroup\$
    – user7467
    Commented Oct 14, 2021 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
    Commented Oct 16, 2021 at 8:59
0
\$\begingroup\$

APL, 13 bytes

0,⍳⍎'00',⍨⍕*0

*0 ⍝ Exponential of zero = 1
⍕ ⍝ Convert to symbol '1'
'00',⍨ ⍝ Append two zeros
⍎ ⍝ Convert to number 100
⍳ ⍝ Make sequence from 1 to 100
0, ⍝ Append zero to the left

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

Rust, 35 bytes

||for c in 0..b'e'{println!("{c}")}

Attempt This Online!

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

C# .NET 4.7.2

With 0, 47 bytes

for(int i=0;i<=0xA*0xA;)Console.WriteLine(i++);

Without 0, 59 bytes

for(int i='a'-'a',j='r'-'@';i<=j+j;)Console.WriteLine(i++);
\$\endgroup\$
0
\$\begingroup\$

Commodore C64 BASIC (THEC64, Ultimate64) 36 PETSCII characters

This can be done as a zero liner in direct mode in Commodore C64 BASIC. It relies on the default value of memory location zero being 47, so this will produce different results on other Commodore machines even though the have the same or a very similar interpreter, and the results will be different on the C128 in C64 mode too in some cases. The screen shot shows a proper representation, but {PI} is the PETSCII Pi symbol in my example, and upper case letters are shifted PETSCII graphics for keyword abbreviations.

x%={PI}+{PI}:fOi=.topE(.)+pE(.)+x%:?i;:nE

Commodore C64, make a listing to print out 0 - 100 inclusive without the characters 1 - 9 inclusive

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

Commodore 64 = 27 Bytes

0FORO=.TO{PI}+{PI}*{PI}*{PI}*{PI}:PRINTO;:NEXT

enter image description here

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

Scratch, 104 bytes

Try it on Scratch!

Requires list x to be visible, which is the norm by default on creation.

define
delete all of[x v
repeat(join(<not<>>+())(join(()+())(()+(
add((item[last]of[x v])+<not<>>)to[x v

enter image description here

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

COMMODORE 64 (improved version) = 25 Bytes

0fOI=ATOA♥("-"):?I:nE

0 FORI=ATOASC("-"):PRINTI:NEXT

"-" = Character 100

To get the correct character in the code you have to poke it in first with POKE2061,100.

\$\endgroup\$
1
  • \$\begingroup\$ You can edit your entries with improved versions that have fewer bytes, leaving your old answer below. Please consider formatting your answers as the standard used by other answers. \$\endgroup\$ Commented Nov 17, 2023 at 16:30
0
\$\begingroup\$

vemf, 5 bytes

0,│d↨

cancats 0 and the integers on [1, 100]

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

Brachylog, 9 bytes

{ẉ₂<}ⁱ¹⁰¹

Try it online!

Technically this doesn’t use 1 or 2, but rather ¹ and ² :)

Explanation

{   }ⁱ¹⁰¹     Iterate 101 times
 ẉ₂           Print the input (implicitely 0 for the first iteration)
   <          Input of the next iteration > current Input
\$\endgroup\$
1 2 3 4 5
6

Your Answer

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