34
\$\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\$
4
  • 9
    \$\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\$ – Redwolf Programs Feb 25 at 0:06
  • 5
    \$\begingroup\$ Is there a requirement to stop printing at 100? \$\endgroup\$ – spuck Feb 25 at 16:44

101 Answers 101

2
\$\begingroup\$

SHENZHEN I/O, 61 bytes, 7¥, 7 Lines

@not
@mov acc dat
@not
tgt acc dat
-mov acc p0
-add x0
slp x0

Outputs 0-100 as simple output, one per time unit. Makes use of the DX300 (XBus <-> Simple Input chip) and LC70G04 (NOT gate), which cost 1¥ each but do not use any power or count as lines of code (the game's measure of code length). These are used to generate a value of 1, which it adds and outputs until it hits 100. The value for 100 is generated using the "not" command, which makes the accumulator 100 if it is value 0, otherwise it sets the acc to 0.

(Not pictured: conversion from simple output to the screen's XBus input, for the visualization.)


SHENZHEN I/O (MCxxxx ASM only), 129 bytes, 8¥, 16 Lines

@not                 | not
@mov acc p0          | mul acc
@mov acc dat         | dgt 0
@not                 | sub p0
add p0               | dgt 0
tgt acc dat          | mul acc
-mov acc x0          | mov acc p0
slp p0               | slx x0

Outputs 0-100 as one XBus output each. Uses only programmable MCxxxx chips, no logic gates or other components. Generates value 1 in a pretty interesting way:

not     # acc = 100
mul acc # 100 * 100 = 999 (max value)
dgt 0   # digit 0 of 999 = 9
sub p0  # 9 - 100 = -91
dgt 0   # digit 0 of -91 = -1
mul acc # -1 * -1 = 1

enter image description here

\$\endgroup\$
2
\$\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\$ – Redwolf Programs Mar 11 at 15:04
  • 1
    \$\begingroup\$ Welcome to the site! You can save 3 bytes by replacing "ba"- with \! 13 bytes \$\endgroup\$ – Cinaski Mar 11 at 15:25
2
\$\begingroup\$

Excel, 23 22 bytes

=SEQUENCE(CODE("e"))-1

Spreadsheet

Original

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

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

VBScript, 33 bytes

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

Competitive answer in VBScript!

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

J, 12 bytes

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

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ i.a.i.'e' for 9 works fine for me... \$\endgroup\$ – Richard Donovan Feb 27 at 20:58
  • \$\begingroup\$ i.'e' returns 101, \$\endgroup\$ – Richard Donovan Feb 27 at 21:05
  • \$\begingroup\$ Sadly that’s a snippet hence not legal according to site rules \$\endgroup\$ – Jonah Feb 27 at 21:51
  • \$\begingroup\$ For more, see this meta discussion \$\endgroup\$ – Jonah Feb 27 at 22:05
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\$

Tcl, 38 bytes

puts 0
time {puts [incr i]} [incr u]00

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Unfortunately it is not 1 to 100. I could do it even cheaper: tio.run/##K0nO@f@/JDM3VaG6oLSkWCE6My@5SCEzthbKKo01MPj/HwA \$\endgroup\$ – sergiol Feb 25 at 20:12
  • \$\begingroup\$ I was about to suggest the code from your comment plus a lame puts 0. Still shorter. \$\endgroup\$ – manatwork Feb 25 at 20:18
  • \$\begingroup\$ @manatwork: Yes it is shorter, thanks. \$\endgroup\$ – sergiol Feb 25 at 20:23
1
\$\begingroup\$

T-SQL, 65 64 bytes

SELECT number FROM spt_values WHERE number<ASCII('e')AND'P'=type

The master database on any SQL server contains a system table called spt_values that (among other things) contain the numbers 0 to 2047. To cap the output I used ASCII('e'), which is 101.

Let me know if you know of a shorter way to generate the number 100 or 101.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Can't ) touch the AND keyword just as ' touches it? Because rewriting the expression as number<ASCII('e')AND'P'=type could save 1 character. \$\endgroup\$ – manatwork Feb 25 at 21:17
  • \$\begingroup\$ Yep, that rearrangement works, @manatwork. Thanks! \$\endgroup\$ – BradC Feb 25 at 21:27
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\$

unsure, 99 bytes

ummmmm uhhhh errrrr uhhh um errrrr um um yeah err heh but um yeah err then uh okay um err then wait

It's not the shortest.

Explanation:

push 101                  ummmmm uhhhh errrrr uhhh um errrrr
push 0 to other stack     um um yeah err heh
loop                      but ... wait
  decrement                 um yeah err
  print + increment other   then uh okay um err then
\$\endgroup\$
2
  • \$\begingroup\$ Maybe I do something wrong, but when testing it with the interpreter you linked, it only prints the numbers up to 99. \$\endgroup\$ – manatwork Feb 28 at 3:34
  • \$\begingroup\$ i misread the challenge, costs 4 bytes i'll fix \$\endgroup\$ – Gold Farmer Sprow Feb 28 at 4:08
1
\$\begingroup\$

Atari 600XL, 22 bytes

Sorry I overread that it's not allowed to use the characters 1-9.

I think it is really stupid to say my language can this is a shorter way, because every language today contains more than a bunch of foreign frameworks. IMHO this "bytes" should be added to the real bytes you need to print values from 0 to 100 on the screen. Therefore a good old Atari 600XL with 16kib of RAM only need: 22 bytes. No other Software is need everything is build in.

Switch the hardware on, wait 2-3sec and type: f.a=0toasc("d"):?a:n.a

'f.' is an allowed shortcut for 'for' and 'n.' is a shortcut for 'next'

Maybe the C64 need also such less bytes.

Everything else need megabytes of extra hidden bytes.

JM2C

\$\endgroup\$
1
  • \$\begingroup\$ Interesting point. It's easy to make a ridiculously complex instruction set language where every unicode character maps to a function, so something like C triggers a routine to output 0-100, and have a 1 byte program hiding behind a vast software library. In fairness though, even the BASIC example does rely on the interpreter built into ROM, so it IS accessing something else, as is everything except machine code. Of course, back in the 8-bit days code-golf wasn't a game - it was standard practise - you had to be clever with the memory. No importing standard libraries using hundreds of MB! \$\endgroup\$ – Caleb Fuller Mar 2 at 4:05
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\$

Forth, 30 bytes

char e false [do] [i] . [loop]

Try it online!

commented:

char e \ ascii value 101
false \ 0
[do] \ loop a fixed number of times
[i] \ retrieve the iterator value
. \ print the top of the stack as a number, followed by a space
[loop] \ end of loop
\$\endgroup\$
3
  • \$\begingroup\$ You can use 'e instead of char e, and 0 is allowed in the challenge. \$\endgroup\$ – Bubbler Mar 7 at 23:48
  • \$\begingroup\$ @Bubbler 'e isn't standard. I already made another post that uses zero. \$\endgroup\$ – binarycat Mar 7 at 23:58
  • 1
    \$\begingroup\$ Our current site culture is that a language's standard doesn't matter much in code golf. It just matters whether the code works in at least one existing implementation of the language (in this case it works in gforth, at least). For example, tips for golfing in C has tons of compiler-specific hacks. But it's fine to stick with the standards, as long as you mention in the post that you're restricting yourself to standard features (otherwise you'll likely get similar comments). \$\endgroup\$ – Bubbler Mar 8 at 0:09
1
\$\begingroup\$

Forth, 26 bytes

char e 0 [do] [i] . [loop]

Try it online!

commented:

char e \ ascii value 101
0
[do] \ loop a fixed number of times
[i] \ retrieve the iterator value
. \ print the top of the stack as a number, followed by a space
[loop] \ end of loop
\$\endgroup\$
2
  • \$\begingroup\$ For golfing improvements of your own post, please don't post a separate answer. You can edit your existing post instead. \$\endgroup\$ – Bubbler Mar 8 at 0:00
  • \$\begingroup\$ I didn't really mean to, I just hit post and apperently I already did somehow? \$\endgroup\$ – binarycat Mar 8 at 0:36
1
\$\begingroup\$

Haskell - 31 19 bytes

Edit: From 31 bytes to 19 bytes, thanks to @binarycat's suggestion of using fromEnum instead of ord, which requires the Data.Char package.

Are imports cheating?

l=[0..fromEnum 'd']

Try it online!

Explanation:

Convert 'd' into it's ASCII integer value using the fromEnum function, which gives 100 and generate a list from 0 to 100.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ why import, fromEnum will do just fine. \$\endgroup\$ – binarycat Mar 7 at 23:49
  • \$\begingroup\$ Didn't know that was a thing! I'm new to Haskell--Thanks for your suggestion :) \$\endgroup\$ – M. Salman Khan Mar 7 at 23:52
  • \$\begingroup\$ you should probably also print the list, instead of just assigning it to a variable. \$\endgroup\$ – binarycat Mar 7 at 23:59
1
\$\begingroup\$

CSASM v2.2.1.2, 143 bytes

func main:
.local a : obj
push 0
pop a
inc a
inc a
push a
inc a
inc a
inc a
push a
mul
dup
mul
pop a
lda 0
.lbl a
inc $a
push $a
dup
print.n
push a
sub
brtrue a
ret
end

Commented and ungolfed:

func main:
    .local onehundred : obj

    ; Calculate 100
    push 0
    pop onehundred
    inc onehundred
    inc onehundred
    push onehundred
    ; Stack: [ 2 ]
    inc onehundred
    inc onehundred
    inc onehundred
    push onehundred
    ; Stack: [ 2, 5 ]
    mul
    ; Stack: [ 10 ]
    dup
    ; Stack: [ 10, 10 ]
    mul
    ; Stack: [ 100 ]
    pop onehundred

    lda 0
    .lbl loop
        ; Print $a
        inc $a
        push $a
        dup
        print.n

        ; Zero is falsy.  Check if $a - 100 == 0
        push onehundred
        sub
        brtrue loop
    ret
end
\$\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\$
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\$ – Zaelin Goodman 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\$ – Zaelin Goodman 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\$ – Zaelin Goodman 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\$
0
\$\begingroup\$

Wolfram Language (Mathematica), 29 bytes

included more for the amusing built-in than the byte count, though this would be something like 9 bytes in the hypothetical mthmca golfing language.

Range[0,FromRomanNumeral@"C"]

Try it online!

And similar, but longer

Range[0, Interpreter["SemanticNumber"]@"hundred"]
\$\endgroup\$
0
\$\begingroup\$

///, 231 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.

\$\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\$ – Samuel Waller Mar 1 at 15:26
0
\$\begingroup\$

Elixir, 42 28 bytes

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

Try it online!

\$\endgroup\$

Your Answer

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