26
\$\begingroup\$

Write a script that outputs A to stdout infinitely.

There shold be no newlines or seperators between the characters

Standard loopholes apply

This is . The shortest solution in each language wins.

\$\endgroup\$
  • 8
    \$\begingroup\$ @FryAmTheEggman I respectfully disagree with this being marked as duplicate. This has a few almost (but not quite!) trivial distinctions from the other questions. For example, printing to stdout without printing a new line, and in the other challenge, looping without output \$\endgroup\$ – Tornado547 Feb 29 at 1:41
  • 3
    \$\begingroup\$ @FryAmTheEggman The other challenge clearly states "producing no output". This is not "producing no output". \$\endgroup\$ – S.S. Anne Feb 29 at 1:46
  • 2
    \$\begingroup\$ @FryAm In Brainfuck, the size is more than 5 times that of the original program. In some languages, output without newlines is hard, especially with sed. I had to use the -z flag just to even remove one. \$\endgroup\$ – S.S. Anne Feb 29 at 15:36
  • 11
    \$\begingroup\$ "Infinite output" is significantly different from "a specific char infinitely many times without new lines". I don't think this is a duplicate. Let's reopen it if this comment gets four upvotes \$\endgroup\$ – Luis Mendo Feb 29 at 22:00
  • 2
    \$\begingroup\$ @Tornado547: ah - so, similar to "unlimited data" cell phone plans. Got it! :-) \$\endgroup\$ – Bob Jarvis - Reinstate Monica Mar 1 at 1:12

106 Answers 106

29
\$\begingroup\$

x86-16, IBM PC DOS, 7 6 bytes

00000000: b041 cd29 ebfc                           .A.)..

Unassembled listing:

B0 41   MOV  AL, 'A'    ; put 'A' into AL
    PRINT: 
CD 29   INT  29H        ; DOS fast console output char in AL
EB FC   JMP  PRINT      ; loop infinitely

enter image description here

As a bonus, if you run this on your IBM 5151 monitor for a few hours this will actually produce infinite output on that screen until the end of time.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ I'd hate to be the idiot that didn't put a screensaver on after running this for even a single minute. \$\endgroup\$ – S.S. Anne Feb 29 at 1:05
  • 3
    \$\begingroup\$ Nice use of an undocumented interrups. \$\endgroup\$ – S.S. Anne Mar 1 at 20:58
  • \$\begingroup\$ @S.S.Anne funny to read today that int 29h is undocumented... when virtually every resource on DOS programming tells about it. \$\endgroup\$ – Ruslan Mar 4 at 9:22
  • 2
    \$\begingroup\$ Actually, this doesn't print to STDOUT as required in the OP. It prints directly to the screen, so you won't be able to e.g. redirect the output to a file as SCREAM > OUT.TXT. \$\endgroup\$ – Ruslan Mar 4 at 9:53
19
\$\begingroup\$

Turing Machine Code, 9 bytes

0 * A r 0

Try it online!

One of the very few times that Turing Machine Code can compete overall.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ indeed! +1 for spotting this really nice use case :D \$\endgroup\$ – RGS Mar 1 at 19:45
17
\$\begingroup\$

brainfuck, 16 bytes

+[+[<]>>+<+]>[.]

Credit to the Brainfuck constants page for 65!

Try it online!

| improve this answer | |
\$\endgroup\$
13
\$\begingroup\$

Bash + core utilities, 16 14 13 bytes

Saved 2 3 bytes thanks to Mitchell Spector!!!

yes|tr \\ny A

Try it online!

Also for 13 bytes (written by Mitchell Spector):

Bash, 13 bytes

printf A;./$0

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Grr... I was going to do this next. Good job, though. \$\endgroup\$ – S.S. Anne Feb 29 at 0:40
  • \$\begingroup\$ 13 bytes: yes|tr \\ny A \$\endgroup\$ – Mitchell Spector Feb 29 at 3:17
  • 1
    \$\begingroup\$ You could also do printf A;./$0 -- this avoids both the filename and PATH issues, but is 3 bytes longer. \$\endgroup\$ – Mitchell Spector Feb 29 at 17:36
  • 1
    \$\begingroup\$ @MitchellSpector That's pretty cool! :-) \$\endgroup\$ – Noodle9 Feb 29 at 18:17
  • 1
    \$\begingroup\$ @JDL Because you have to get rid of the newlines. You've got to generate a continuous stream of As, not one of A\ns that yes A will generate. They're actually \nAs which is what this post uses. \$\endgroup\$ – Noodle9 Mar 2 at 12:38
12
\$\begingroup\$

Python 3, 25 22 bytes

while 1:print(end='A')

Saved 3 bytes thanks to xnor

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Traditionally, you don't answer your own question for a couple of days. However, that's usually for more complex challenges. This one is quite trivial, so I suppose it's OK. \$\endgroup\$ – S.S. Anne Feb 29 at 0:22
  • 3
    \$\begingroup\$ You can actually do print(end="A"). \$\endgroup\$ – xnor Feb 29 at 0:24
  • 1
    \$\begingroup\$ Why not just Print('A')? \$\endgroup\$ – BruceWayne Mar 1 at 23:34
  • 2
    \$\begingroup\$ @BruceWayne, print('A') includes the newline \$\endgroup\$ – PenumbraBrah Mar 2 at 1:45
11
\$\begingroup\$

Apple II 6502 Assembly code, 7 bytes

L1: A9 C1      LDA #'A'
    20 ED FD   JSR COUT
    50 F9      BVC L1
| improve this answer | |
\$\endgroup\$
9
\$\begingroup\$

Vim, 14 7 10 bytes

qqiA^[@qq@q

Added 3 bytes to fx a bug kindly pointed out by David.

If you fire up vim (with no command line options) and type in these key strokes (^[ is the esc key) then the screen will fill up with A's.

Explanation:

qqiA^[@qq@q
qq          Start recording macro-q
  i         Enter insert mode
   A        Insert A
    ^[      Exit insert mode
      @q    Call macro-q from within macro-q
        q   Stop recording macro-q
         @q Call macro-q

Note: You'll probably have to kill that session of vim to stop it!

You can try to stopping the macro with ctrl-c, if that works you can exit with :q!<Enter>.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Does ^z kill $! work? \$\endgroup\$ – S.S. Anne Feb 29 at 1:10
  • \$\begingroup\$ @S.S.Anne You'll have to kill it from another terminal on Linux. Windows you can use the task manager. \$\endgroup\$ – Noodle9 Feb 29 at 1:11
  • \$\begingroup\$ Or you can just click on the screen, ^c and type :q!. I knew there was some way to do it. \$\endgroup\$ – S.S. Anne Feb 29 at 1:13
  • \$\begingroup\$ You have to click on the Vim window first. \$\endgroup\$ – S.S. Anne Feb 29 at 1:54
  • 1
    \$\begingroup\$ The trick being that you call the macro while still creating it. Nice! \$\endgroup\$ – Jonta Mar 2 at 15:24
7
\$\begingroup\$

><>, 4 bytes

'A'o

Try it online!

How it works

The instruction pointer begins at left, and its initial direction is to the right.

' starts string parsing mode. Everything until the next ' will be interpreted as individual characters, that will get pushed onto the stack. So A pushes that character, and then the second ' ends string parsing mode.

o pops the character from the stack and outputs it to STDOUT.

The instruction pointer has now reached the end of the code, so it wraps around to the initial position and keeps moving to the right, causing an infinite loop.

| improve this answer | |
\$\endgroup\$
6
\$\begingroup\$

Burlesque, 3 bytes

@'A

Try it online!

@ is an odd operator.

  • For integers, it converts to double (@1 => 1.0)
  • For two letters, it pushes both to the stack individually (@az => 'a, 'z)
  • For characters it prints the character infinitely as a string (@'a => "aaaaaaaaaa....")
  • For anything else, it does nothing and just remains on the stack (@1.0 => @, 1.0).
@   # A symbol which does odd things. For a char, it repeats infinitely.
'A  # Literal A
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Is it useful for the "anything else" scenario? \$\endgroup\$ – S.S. Anne Mar 5 at 18:28
  • \$\begingroup\$ @S.S.Anne Not really, I suspect you could push it into a block and eval it. But I've never found cause to. \$\endgroup\$ – DeathIncarnate Mar 6 at 10:10
6
\$\begingroup\$

C (gcc), 20 bytes

A(){A(putchar(65));}

-4 bytes thanks to ceilingcat!

How could I have forgotten recursion...

Try it online!

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

Malbolge, 2163 2069 1881 1787 bytes

b'a;$9"~}HG{iyxwuu?O=pL:]mHj5!3DCezRQ=+^:('&Y$#m!1So.QOO=v('98$65a!}^{@hyf<WV9sr%4#I20FEJVBfw)btOr@#!7~|4{y1xv.us+rp(om%lj"ig}fd"cx``uz]rwvYnslkTonPfOjiKgJeG]\EC_X]@[Z<R;VU7S6QP2N1LK-I,GF(D'BA#?>7~;:9y16w43s10)p-,l*#(i&%e#d!~``{tyxZpuXsrTTongOkdMhg`Hd]ba`_^W@[ZYXW9UNSRQPOHMLKJ-++FE''<A$?>=<;:387xw43s10/(-&m*)('&}${d!~}|^zyxwvutmVqpiRQlkjiKafedc\E`_^@\[ZYX;V9NMRQ42NGLK.IH*F?DCBA$#>7~;{{8xx5uu2rr/oo,ll)ii&f|e"!aw`{z\r[vXnmVTpongPkNihgJ_dcFa`B^]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u(IeH6F[`~1A@hZSRuc9rrqK4\lMkK-CHAS(ubBN:L!J6}kXW1wfv3Prr`;o,%IH(4~}|d/@Q>v{;(\wZ$W4V1}/R-PxjvuKf_$G#nZ}B|z>-xwQc88qR^nO1GL|JVyGeEca&$$?8[6|GjWxg/AR2POq(o,JH6j4&C$0@@-a`^:y[q6H54rq0BR--N*chJ&_%cF!CY}Ai.-wwWV(s6%4o\lZkKDz,fdRQ

Try it online!

This was built with Prof. Masahiko Sakai's LAL toolchain from the following source code.

PROGRAM_START_TO ENTRY@Argh
ROUTINE Argh {
ENTRY:
ROT A
A: 0000021020t
JMP REV_JMP
REV_JMP:REV JMP
OUTPUT
DUP
JMP REV_JMP
}

Online LAL assembler

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

Hexagony, 3 bytes

A.;

Try it online!

 A .
; . .
 . .

A sets the value of the current memory edge to A (ASCII 65).

. is a no-op that places the next command on a new row.

; prints the value of the current memory edge to stdout.


The no-op is required because the instruction pointer never returns to the top row after executing A. It only loops over the second and third rows.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ .A; also works. \$\endgroup\$ – user92069 Mar 2 at 5:34
5
\$\begingroup\$

Unreadable, 208 bytes

'"""""'"""'"'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'"""

Try it online!

Explanation (A has codepoint 65):

'"""""'""" while(1≠0)
'"         print unicode character number
'"" (×64)  1+1+1+… (64 times)
'"""       1
| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

Pyramid Scheme, 111 98 bytes

     ^
    / \
   /do \
  ^-----^
 /1\   / \
 ---  /out\
     ^-----
    / \
   /chr\
  ^-----
 / \
/65 \
-----

Try it online!

Edit:

98 bytes thanks to @Jo King and height-0 pyramids. Also, chr 65 is truthy.

   ^
  / \
 /do \
^-----^
-^   / \
 -^ /out\
  -^-----
  / \
 /chr\
^-----
-^
 -^
 / \
/65 \
-----

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ O! Thanks! I must admit that I did not know about the height-0 pyramids. \$\endgroup\$ – MarcinKonowalczyk Jul 26 at 8:33
4
\$\begingroup\$

Keg, 3 bytes

{A,

Try it online!

That was fun! This is literally an infinite loop that prints As over and over

| improve this answer | |
\$\endgroup\$
4
\$\begingroup\$

Common Lisp, 15 bytes

(loop(princ'a))

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This is so... English. \$\endgroup\$ – Wezl Jun 29 at 18:27
3
\$\begingroup\$

Pyth, 4 bytes

#p\A

Explanation:

#p\A
#    While 1:
 p   Print without newline
  \A Character A

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

05AB1E, 4 bytes

['A?

Try it online!

[         # infinite loop
 'A       # "A"
   ?      # print without a trailing newline
| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

x86-16 machine code (DOS 1+), 8 bytes

Disassembled listing (objdump -D -bbinary -mi8086 scream.com):

   0:   b4 02                   mov    $0x2,%ah
   2:   b2 41                   mov    $0x41,%dl
   4:   cd 21                   int    $0x21
   6:   eb f8                   jmp    0x0

Output (DOSBox 0.74, and a lot faster than it looks):

Here's my ldscript and command-line options for anyone interested:

OUTPUT_ARCH(i8086)
SECTIONS {
        . = 0;
}
ENTRY(_start)
OUTPUT_FORMAT(binary)

commands:

as --32 scream.s -o scream.o
ld scream.o -Tldscript.lds -o scream.com
dosbox ./scream.com

and unmolested scream.s file:

_start:
    mov $0x02, %ah
    mov $0x41, %dl
    int $0x21
    jmp _start
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Tested and works just fine as advertised on DOS 1.0! \$\endgroup\$ – 640KB Feb 29 at 2:05
  • \$\begingroup\$ @640KB I guess I should give credit to Ralf Brown's Interrupt List while I'm at it. \$\endgroup\$ – S.S. Anne Feb 29 at 2:08
  • \$\begingroup\$ @640KB I was into this a while back but I stopped. It was fun writing low-level code and learning about all the stuff you could and couldn't do. \$\endgroup\$ – S.S. Anne Feb 29 at 2:16
  • 1
    \$\begingroup\$ @640KB Roll 'em once and use 'em everywhere. \$\endgroup\$ – S.S. Anne Feb 29 at 2:33
3
\$\begingroup\$

Haskell, 20 bytes

main=putStr$cycle"A"

Try it online!

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Also 20 bytes: main=putStr"A">>main \$\endgroup\$ – cole Mar 1 at 18:45
  • \$\begingroup\$ 19 bytes: m@main=putStr"A">>m \$\endgroup\$ – Lynn 21 hours ago
3
\$\begingroup\$

Ruby, 12 bytes

loop{$><<?A}

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Jelly, 4 bytes

A niladic link:

”AȮß

Try it online!, or check how it works below. If the "A" could be program input, we could get away with only two bytes: Ȯß

”A   The character literal "A"
  Ȯ  Print it and return it,
   ß and recursively call this same link.
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ How long does it take for the stack to overflow? \$\endgroup\$ – TheOnlyMrCat Mar 2 at 20:49
  • \$\begingroup\$ I didn't run it locally, only on TIO... And it seems TIO stops the execution because of the output size. So maybe the implementation of the recursive call is actually a loop? Because in Python the usual recursion depth is 1000 or 1024 and I manage to output way more than 1024 "A"s..? Just check the TIO link. \$\endgroup\$ – RGS Mar 2 at 22:01
  • 1
    \$\begingroup\$ Here. The interpreter sets the recursion limit to 1 << 30. \$\endgroup\$ – user92069 Mar 3 at 10:56
3
\$\begingroup\$

Ruby, 12 bytes

1while$><<?A

Try it online!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Piet, 30 26 Codels

It's a .png 13x2 codels, a few are technically not used (4 white unused, 1 white as transition and 1 black to change direction). But since I don't know how to compress it further, I still count them.

Original file (codel size 1): Codel Size 1

With codel size 10: Codel Size 10

For some reason, the codel size 10 looks disproportional. Maybe it's an issue with the IDE

Pseudo code (incl. stack):

push 2    | Stack: 2
push 4    | Stack: 2, 4
push 2    | Stack: 2, 4, 2
push 4    | Stack: 2, 4, 2, 4
*         | Stack: 2, 4, 8
*         | Stack: 2, 32
*         | Stack: 64
push 1    | Stack: 64, 1
+         | Stack: 65
dup       | Stack: 65, 65
out(char) | Stack: 65 | Output: A

dup and out(char) are repeated indefinitely.

Try it online!

This is my first submission here and my first "real" program in Piet. I'm sure it still has some room for improvement, but I just wanted to share (what I think of as) a lovely language :D

Edit: Compressed down from 15x2 to 13x2.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Lua, 22 bytes

::a::io.write"A"goto a
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I do think this is strictly suppossed to be an uppercase "A". Doesn't change your byte count though. \$\endgroup\$ – ouflak Mar 3 at 8:24
  • \$\begingroup\$ Dang it, completely forgot about goto! Fun fact: solutions with while and recursion both use 25 bytes. \$\endgroup\$ – val says Reinstate Monica Mar 4 at 10:57
3
\$\begingroup\$

PowerShell 25 23 bytes

for(1){Write-Host -n A}

Try it online!

A works same as "A" and saves 2 bytes.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Labyrinth, 5 bytes

65
".

Try it online!

Simple square loop. Push the number 65, pop and print as charcode, and loop through a no-op.

Labyrinth, 5 bytes

<>.56

Try it online!

I think I found a way to loop through single line of program! (Except that the commands are necessarily backwards, and each of <> pops one value from the stack and uses it as an offset, so the loop should begin with <_>_ instead if the stack is non-empty at the boundary.)

<>.56  At start, IP runs "<" which cyclically shifts the row along with the IP
>.56<  Now IP is at the end of the strip, which forces it to run backwards
   6   Run commands in this order, printing an 'A'
  5
 .
>      Cyclically shift the row to the right
<>.56  Continue running to the left, now stepping on "<" again
       which causes IP to wrap through the edge and run in a loop

Labyrinth, 6 bytes

19
`
.

Try it online!

Uses -191 % 256 == 65. Runs back and forth along the linear path .`19, starting at 1 facing right.

Labyrinth, 5 bytes

~9
.1

Try it online!

Another -191.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I mean, why not just _65.? Or *65. to avoid memory filling up \$\endgroup\$ – Jo King yesterday
2
\$\begingroup\$

Octave / MATLAB, 21 bytes

while fprintf('A')end

Try it online!

Explanation

fprintf('A') prints 'A' to STDOUT and returns the number of printed characters, that is, 1. This number is used as condition for the while...end loop, which thus becomes infinite.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

AWK, 28 bytes

BEGIN{for(ORS="";;)print"A"}

Try it online!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I think using the END block instead of the BEGIN block works. \$\endgroup\$ – dingledooper Mar 6 at 3:45
2
\$\begingroup\$

sed 4.2.2 -z, 14 bytes

s/\n/A/g;:
p
b

Sed 4.2.2 was the last version to support an empty label name.

Try it online!

sed -z, 16 bytes

s/\n/A/g;:r p
br

After that, golfing is slightly more expensive.

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Unfortunately, this prints null bytes between the As (due to the -z flag). \$\endgroup\$ – user41805 Mar 5 at 18:21
  • \$\begingroup\$ What does the g at the end of the substitution help with? \$\endgroup\$ – Wezl Jun 29 at 18:30
  • \$\begingroup\$ @Wezl Nothing, in this case. It's just a global replacement, and I have a habit of typing it. \$\endgroup\$ – S.S. Anne Jun 29 at 19:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.