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.
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this communityPrint 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.
=SEQUENCE(ROW(),,0)
in A101?
\$\endgroup\$
Oct 25, 2021 at 18:57
i0<Esc><C-a>s<C-r>=r <C-r>"0<C-r>")
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):
iYp<C-v><C-a>0<Esc>d^@=!0
00@-
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
class p {public static void main(String[] args){int i='A'/'A';while(i<=(int)'d')System.out.println(i++);}}}}
for(i=0;+!print(i)+'00'-i++;);
Jo king saves more bytes that I can count :)
e($!#^$_^_
@)
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
0) @
0 \(
)#":
(!
Push 101 ()
is increment and 0
is "append zero" command), and run "print stack height - 1, dup, decrement" until the top becomes zero.
0)
0
)}:!
" \
@({)
Keep track of two values a=0
and b=101
, print a
and increment and decrement b
until b
becomes zero.
Filename must be x
; this is for extra one byte.
echo $[x++]
a=x
((x>${#a}00))||. x
for i=0,0xA..0 do print(i)end
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:
for i=0 to asc("d")
msgbox i
Next
Competitive answer in VBScript!
for(n=0;++n<+atob`MTAx`;)alert(n)
-15 bytes thanks to @EliteDaMyth
+atob`MTAx`
for 11 bytes
\$\endgroup\$
for(n=0;++n<+atob`MTAx`;)alert(n)
this is 33 bytes
\$\endgroup\$
atob`MTAx`;
\$\endgroup\$
Feb 23, 2021 at 17:15
(apply pr(range(int\e)))
If it is acceptable that output is wrapped in parentheses, then we can remove apply
for -6 bytes.
i++
into Console.WriteLine()
. Try it online!
\$\endgroup\$
Feb 23, 2021 at 18:22
<
rather than <=
, along with the byte save from my last comment Try it online!
\$\endgroup\$
Feb 23, 2021 at 18:33
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
aa*r\
@Q
&d\
O
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
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.
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
Lò
This outputs a list of numbers from 0 to 100 separated by commas.
Lò
L -Number 100
ò -Creates an inclusive range from 0 to L, and return it in the output
#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!
\newcount~\loop\advance~`^^A\the~ \ifnum~<`^^%\repeat\bye
Makes uses of these two tricks:
^^A
becomes NUL
.'e'{}/,`
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'{}/,' '*
Solution:
!"e"
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
#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\$.
\001.r.-.z.c.n,.o\001.+.ce.a
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
e.e
.c.w\001.-.e.+.n .o.d.a
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
0
. Which is what makes this challenge interesting, IMO. \$\endgroup\$