title: Scream very loudly

text:
# Question
Title: Scream very loudly
Write a script that outputs `A` to stdout infinitely.

There should be no newlines or separators between the characters.

Standard loopholes apply.

This is . The shortest solution in each language wins.

# Answer
# 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

```

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.
> 37 votes

# Answer
# 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.
> 29 votes

# Answer
# brainfuck, 16 bytes

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

```

Credit to the Brainfuck constants page for 65!

Try it online!
> 21 votes

# Answer
# Taxi, 279 bytes

```
Go to Post Office:w 1 l 1 r 1 l.[A]A is waiting at Writer's Depot.A is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Zoom Zoom:n.Go to Post Office:w 3 l 2 r 1 l.Switch to plan A.

```

Try it online!

---

This is an interesting challenge because it requires both refueling infinitely for gas and getting enough passengers to pay for the gas. If passengers paid enough to pay for the gas used to transport them, the following would be enough:

```
Go to the Post Office: west 1st left, 1st right, 1st left.
[loop]
"A" is waiting at the Writer's Depot.
Go to Go More: west 1st right, 1st left, 1st left, 2nd right.
Go to the Writer's Depot: west 1st right.
Pickup a passenger going to the Post Office.
Go to the Post Office: north 1st right, 2nd right, 1st left.
Switch to plan "loop".

```

However, because passengers do not pay enough this results in only 54 * `A`, crashing the program once we are out of fuel. We can also go to Zoom Zoom to buy fuel, it's way cheaper to buy here allowing us to get 79 * `A`. Luckily, picking up two passengers at a time solves this problem of not earning enough per iteration. The code can be golfed further by removing quotes for strings that don't contain whitespace and minimising the directions. Ungolfed it looks like this:

```
Go to the Post Office: west 1st left, 1st right, 1st left.
[loop]
"A" is waiting at the Writer's Depot.
"A" is waiting at the Writer's Depot.
Go to the Writer's Depot: west 1st right, 1st left, 2nd left.
Pickup a passenger going to the Post Office.
Pickup another passenger going to the Post Office.
Go to Zoom Zoom: north.
Go to the Post Office: west 3rd left, 2nd right, 1st left.
Switch to plan "loop".

```

## Two 321 byte answers

Before I realised I could go to Zoom Zoom with two passengers I found the following solutions of 321 bytes which have some interesting tricks not used in the shorter solution…

```
Go to Post Office:w 1 l 1 r 1 l.[A]"A"is waiting at Writer's Depot."A"is waiting at Writer's Depot."A"is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.[B]Switch to plan C i.Pickup a passenger going to Post Office.Switch to plan B.[C]Go to Go More:s 1 l.Go to Post Office:e 1 l 1 r 1 r 1 l.Switch to plan A.

```

Try it online!

**or**

```
Go to Post Office:w 1 l 1 r 1 l.[A]"AAA"is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 2 l.Pickup a passenger going to Chop Suey.Go to Zoom Zoom:n.Go to Chop Suey:w 1 l 3 r.[B]Switch to plan C i.Pickup a passenger going to Post Office.Switch to plan B.[C]Go to Post Office:s 1 r 1 l 2 r 1 l.Switch to plan A.

```

Try it online!

---

Using Go More to get Fuel, even picking up the maximum of three passengers does not give enough money to loop infinitely, so I had to think about it smarter. If we pick up passengers sooner and take them on a longer route through the city they will pay more for the ride. Going to Writer's Depot before getting fuel results in 70 * `A`. If we pick up three passengers using this route, we can loop infinitely.

Picking up three passengers going to the same destination can be done more byte-efficient than using the same code thrice. Using `Switch to plan "name" if noone is waiting` we can pick up a single pasenger until all three are picked up. The quotes around the plan name are optional and it any word after it get's interpreted as `if noone is waiting`. Using this we get our first 321 byte solution, the code below is the ungolfed version:

```
Go to Post Office: west 1st left, 1st right, 1st left.
[loop]
    [Setup 3 * "A"]
"A" is waiting at Writer's Depot.
"A" is waiting at Writer's Depot.
"A" is waiting at Writer's Depot.
Go to Writer's Depot: west 1st right, 1st left, 2nd left.
    [Pickup 3 * "A"]
[before pickup]
Switch to plan "after pickup" if noone is waiting.
Pickup a passenger going to Post Office.
Switch to plan "before pickup".
[after pickup]
    [Get Gas]
Go to Go More: south 1st left.
    [Print 3 * "A"]
Go to Post Office: east 1st left, 1st right, 1st right, 1st left.
Switch to plan "loop".

```

---

But there's more! Setting up three different passengers to pick up costs quite a few of bytes. If we instead split up the string `"AAA"` we can eliminate two lines setting up passengers, at the cost of going past Chop Suey. With this we don't need to go out of our way to visit the Go More gas station anymore, Fueler Up is on our route and Zoom Zoom is very easily accessible too. Looking into Fueler Up, it's the most expensive, in fact, it's so expensive that you don't get enough money even taking three passengers! We can only print 561 * `A`, 187 loops of three passengers, but not infinite as we are trying. Luckily, Zoom Zoom the cheapest gas station does not require much extra routing at all and taking this route does allows us to enter another infinite loop.

```
Go to Post Office: west 1st left, 1st right, 1st left.
[loop]
    [Setup 3 * "A"]
"AAA" is waiting at Writer's Depot.
Go to Writer's Depot: west 1st right, 1st left, 2nd left.
Pickup a passenger going to Chop Suey.
    [Get gas]
Go to Zoom Zoom: north.
Go to Chop Suey: west 1st left, 3th right.
    [Pickup 3 * "A"]
[before pickup]
Switch to plan "after pickup" if noone is waiting.
Pickup a passenger going to Post Office.
Switch to plan "before pickup".
[after pickup]
    [Print 3 * "A"]
Go to Post Office: south 1st right, 1st left, 2nd right, 1st left.
Switch to plan "loop".

```

It's sad that this does not safe any bytes, but it's the second time I got two answers with the same number of bytes which I think is cool! (See this DDoouubbllee ssppeeaakk challenge.)

I also realised when I was about to publish that *all* strings without whitespace can be written without quotes. That golved my actual solution a bit more and does not leave the 321 byte solutions the same length anymore. Even so I still publish this explanation too, because the repeat to pickup three passengers is useful and using Chop Suey was fun :)
> 20 votes

# Answer
# 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!

Yet another 13 byter, this one written by pxeger:

# Bash, 13 bytes

```
yes|tr -c A A

```

Try it online!
> 18 votes

# Answer
# Python 3, ~~25~~ 22 bytes

```
while 1:print(end='A')

```

Saved 3 bytes thanks to xnor

Try it online!
> 14 votes

# Answer
# Poetic, 73 bytes

```
why cant i cease,i say
i scream"A"out loud in agony
i cry,as i shouted on

```

Try it online!
> 14 votes

# Answer
# AHHH, 40 bytes

```
AHHHHhhHHHhHHHhHHHhHHHHhHhhHHHHHHhhhhhhh

```

The right language for the job.

Try it online!

### Explanation

```
AHHH  Start program
HhhH  Increment cell to 1
HHhH  Double cell to 2
HHhH  Double cell to 4
HHhH  Double cell to 8
HHHh  Square cell to 64
HhhH  Increment cell to 65
HHHH  Loop while cell is nonzero:
Hhhh    Output cell as ASCII character
hhhh  End loop

```
> 14 votes

# Answer
# 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>`.
> 13 votes

# Answer
## Apple II 6502 Assembly code, 7 bytes

```
L1: A9 C1      LDA #'A'
    20 ED FD   JSR COUT
    50 F9      BVC L1
```
> 12 votes

# Answer
# Piet \+ ascii-piet, 12 bytes (2×6=12 codels)

```
ttttlIauqasj

```

Try Piet online!

In grid form:

```
ttttli
auqasj

```

Represents the following Piet program:

### How it works

```
pointer      command    stack
t<4> -> l    Push 4     [4]
l -> i       Dup        [4, 4]
i -> j       Dup        [4, 4, 4]
j -> s       *          [4, 16]
s -> a       *          [64]
a -> q       Push 1     [64, 1]
q -> u       +          [65]
u -> a       OutC       [] Print 'A'
a -> t       %          [] Stack underflow; ignored

```
> 12 votes

# Answer
# C (gcc), 20 bytes

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

```

*-4 bytes thanks to ceilingcat!*

How could I have forgotten recursion...

Try it online!
> 11 votes

# Answer
# 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.
> 9 votes

# Answer
# APL (Dyalog Extended), ~~11 9~~ 7 bytes

```
⍞←⍣≠'A'

```

Try it online!

-2 bytes from Bubbler.

-2 bytes from Adàm using forbidden hacky APL magic.

Older answer:

```
{⍞←'A'⋄∇⍵}0

```

### Explanation

```
{⍞←'A'⋄∇⍵}0
      ⋄     separator (arguments will be evaluated left to right)
 ⍞←'A'      Print 'A' without newline
       ∇⍵   Call function again with the same right argument
{        }0 Call first time with 0(any number works)

```

Try it online!
> 9 votes

# Answer
# Malbolge, ~~2163 2069 1881 1787~~ 1693 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^]\UZ=RWV8TSLQ4ON0LE.IHA)E>'BA:?!7~5|38y6/v321q).-&m*)i'&%|{d!~}_{zs\wvutsUqTonPlOjiKgJedFbE`_A]@[Z<X;VU7S6QP22GL/JIB+FEDC%;@?>7~;:987w5v32r0)p-,+k)('~g$#"b~w|uz]xwvutsrqTinQlOjLhgfeH]bE`CB]\>ZSXWVUTSRQPON1LE.I,+*((&&$$""~~||zzxxv4u210/(-n+l)(i&g$ddy~}`u^]\ZZotsrTjShQOOMMKgfeG]F[DB^]?[T=R;9UTS5K4I200..,,*F)DC&A:#>=~;|9yyx/vutrrp.-,l$k"i~ge#"!aw`u^\\ZZXXVrqpRhQfOMMKKIeHcbECC^W\?>=;W:UT7R5PIN1L/.,,*FED&<%:#!!}}{987w/v-trrppnnllj(i&%ee"!xa|_^\x[vutWrqjSnQPNNLLJJHHFFDDB^A\[==XWVOT7R542N1LKJ-HGF?D'B%$""~<;:z2y0wu321q)p'nl*)(h~g|eccaa__]][[YuXsrTTonmleNiLgfeG]F[`C^]\?ZYXWP9T76442NML.D-B+)EDC%;$9"~<;:z2y0wuussqqoommk)j'&ff#"!~}v{^y\wvXtmVkpSnmlOjihgf_dGbEDBB@\?==R;PUTS5K4I200..,,**(DCB$:#8!}}{{yyw5v321r/.-,+*#j'h%$#cybw`^^s\ZvuWslUjSQQOOMMKgJedc\E`_B]@[==<QV9T76KPON0F/D-++))'CBA#9"7~||z87w5.u,sqqoommkki'h%$#d!xa`{^\\qZotsUqjShmPkjMhKfe^cFEDYB@@>>S<:VU7SL5J311//--++))'C&A@#>!<;49z76w4u2rr).-n%lkjhhffddb~}|^t]rwZXXmrUpoRmfONihgI_H]FD`_^@V?T=;;9977553311/K.IH+))>C&%@?>~6}49z76w4u,1rq.o,+l)j'~g$#d!b}__^yr[ZuXsrUSSnmfkjiLKfedFbaDY^A\[>Y<WVOTSRQ43H1FKJI+A*?(&BA@"8!6}{987w/v-trrppn,mkk"'&%e{dyb``^^\\ZZXXW22}Rn-O>Nvu(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!

-94 bytes thanks to @user100411.

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
REV JMP
REV_JMP:REV JMP
OUTPUT
DUP
JMP REV_JMP
}

```

Online LAL assembler
> 8 votes

# Answer
# \>\<\>, 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.
> 7 votes

# Answer
# 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

```
> 7 votes

# Answer
# 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

```
> 7 votes

# Answer
# 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):

With 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.
> 6 votes

# Answer
# 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

```
> 5 votes

# Answer
# Common Lisp, 15 bytes

```
(loop(princ'a))

```

Try it online!
> 5 votes

# Answer
## Lua, 22 bytes

```
::a::io.write"A"goto a

```
> 5 votes

# Answer
# Clojure, 16 bytes

Another Clojure version saving 2 bytes over previous solution, posted as a separate answer because I don't have comment rights yet.

```
(while 1(pr 'A))

```

Try it online!
> 5 votes

# Answer
# 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!
> 5 votes

# Answer
## NDBall, 52 bytes, 7 instructions in 2 dimensions

```
(0)>0
(1)+
(2)Y[65,>1,>0]
(3)p
(4)<0
(2,1)<0
(0,1)<1

```

In essence, this just loops the ball on an add 1 loop until it reaches 65, then it bounces back and forth over p repeatedly printing "A"
> 5 votes

# Answer
# Bitcycle, ~~25~~ ~~16~~ 14 bytes

```
~1000~!
>0010^

```

Try it online!

Output as a stream of bits. -9 thanks to DLosc. -2 thanks to JoKing.
> 5 votes

# Answer
# Java (JDK), ~~85~~ ~~77~~ 34 bytes

```
v->{for(;;)System.out.print("A");}

```

Try it online!

Massive thanks to @Kevin for the lambda solution. I really need to learn how to do that.

## Old Answer

```
class M{public static void main(String[]args){for(;;)System.out.print("A");}}

```

Try it online!

It's a full program and can probably be golfed if I knew how lambdas work in java. Oh well.
> 4 votes

# Answer
# Perl 5, 15 bytes

```
print'A'while 1

```

Try it online!
> 4 votes

# Answer
# International Phonetic Esoteric Language, 9 bytes

Derived from my answer to "Shortest code to produce infinite output".

```
"A"10ɑbuɒ

```

## Explanation:

This works because the `ɒ` instruction don't do anything with the loop index except to check if `index < limit`. If it is, it loops back to its associated `ɑ`. Otherwise it exits the loop (index manipulation is handled with `e` adn `ø`).

```
"A"10ɑbuɒ
"A"       (Push "A")
   10     (Loop bounds: 0 to 1)
     ɑ    (Start loop)
      b   (Copy top)
       u  (Print with no trailing)
        ɒ (End loop)

```
> 4 votes

# Answer
# Alice, ~~4~~ 3 bytes

It's a pretty simple Cardinal mode answer.

-1 bytes thanks to Martin Ender

```
'AO

```

Try it online!

## Explanation

```
'A  - Push "A"
  O - Output as character
    - The IP wraps around to the left, and repeats.

```
> 4 votes

# Answer
# Seed, 8 bytes

```
3 141509

```

Try it online!
> 4 votes

# Answer
# Windows Batch, 16 bytes

```
:a
echo a
goto a

```
> 4 votes

# Answer
# Go, 38 bytes

```
import."fmt"
func A(){for{Print("A")}}

```

Try it online!
> 3 votes

# Answer
# Keg, 3 bytes

```
{A,

```

Try it online!

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

# Answer
# Haskell, 20 bytes

```
main=putStr$cycle"A"

```

Try it online!
> 3 votes

# Answer
# Ruby, 12 bytes

```
loop{$><<?A}

```

Try it online!
> 3 votes

# Answer
# 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.

```
> 3 votes

# Answer
# Ruby, 12 bytes

```
1while$><<?A

```

Try it online!
> 3 votes

# Answer
# Brian & Chuck, 8 bytes

```
A{?
B{.?

```

Try it online!

```
Brian:
A   constant "A"
{?  restart Chuck's code

Chuck:
B   (just a filler, this will be ignored)
{   go to start of Brian's code
.   print char
?   toggle to Brian

```
> 3 votes

# Answer
# Python 2, 19 bytes

This might be cheating as it can only work on a terminal, since each space added in between "A" is removed with a backspace char.

```
while 1:print'\bA',

```
> 3 votes

# Answer
# PowerShell ~~25~~ 23 bytes

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

```

Try it online!

`A` works same as `"A"` and saves 2 bytes.
> 3 votes

# Answer
## ZX Spectrum machine code, 5 bytes

```
3E 41 LOOP: LD A, 'A'
D7          RST 16
18 FB       JR LOOP

```

`RST 16` is the Spectrum's character output interrupt. It will prompt you to "scroll?" on the 705th and every subsequent screenful of characters; if you press `N`, `STOP` or `BREAK` it will abort with error `D BREAK - CONT repeats`.

I've hand-assembled this so the opcodes might be incorrect.
> 3 votes

# Answer
# Wolfram Language (Mathematica), 28 bytes

```
$Output~WriteString~A~Do~∞

```

Try it online!

Most ways to output in Mathematica will include a trailing newline.
> 3 votes

# Answer
# TeX (to file), 10 bytes

```
\def~{A~}~

```

# TeX (to STDOUT), 19 bytes

```
\def~{\write0{A}~}~

```
> 3 votes

# Answer
# 05AB1E, 4 bytes

```
'A[?

```

Try it online!

```
'A    # push "A"
  [   # repeat forever...
   ?  # output top of stack to STDOUT without newline
      # (implicit) exit infinite loop

```
> 3 votes

# Answer
# 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.
> 3 votes

# Answer
## Starry, 41 35 bytes

-6 bytes, thanks to @ovs

Pushing values in Starry is pretty annoying, so the first 33 27 bytes are devoted to pushing the value of 'A' into the stack.

```
             + +  *      +*` + . +'

```

```
    13+    push 13-5
    1+     duplicate
    2*     multiply (top of stack is 64)
    6+     push 6-5
    0*     add (top of stack is 65)
    0`     label 0
    1+     duplicate
    1.     pop and print as char ('A')
    1+     duplicate
    0'     pop 'A', goto label 0

```

(The number at the beginning of each line signifies the number of spaces)
> 3 votes

# Answer
# CBL, 7 bytes

`°¸A;«.»`

CBL is a language that I am developing. This answer may not be up-to-date with the latest syntax. I have not coded an interpreter yet.

A breakdown:

```
°¸A;«.»

°       <; Add following value(s) to current array value
 ¸A;     <; A as it's value(in the CBL codepage)
    « »   <; Loop(since there is no parameter, it loops infinitely)
     .     <; Print current array value

```

## COBOL, 80 bytes

Just for fun.

```
IDENTIFICATION DIVISION.PROGRAM-ID.A.PROCEDURE DIVISION.A.DISPLAY 'A'.PERFORM A.

```

https://www.tutorialspoint.com/compile\_cobol\_online.php
> 3 votes

# Answer
# Among Us, ~~83~~ 80 bytes

*-3 bytes thanks to ovs*

```
VENTED RED SUS LIME SUS SUS SUS SUS SUS SUS RED SUS BLUE SUS WHO GREEN SUS WHERE

```

Explanation:

```
VENTED                          A2 += 10   (A2 = 10)
RED SUS                         A1 += 1    (A1 = 1)
LIME SUS SUS SUS SUS SUS SUS    A1 *= 2 6x (A1 = 64)
RED SUS                         A1 += 1    (A1 = 65 = 'A')
BLUE SUS                        PUSH A1
WHO                             while (A2 != stack_top) {
GREEN SUS                           print(stack_top)
WHERE                           }

```

Documentation of the language doesn't match the interpreter, this goes off of what runs on the interpreter. (creator, please fix).

Try it online!
> 3 votes

# Answer
# Pyth, 4 bytes

```
#p\A

```

Explanation:

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

```

Try it online!
> 2 votes

# Answer
# Octave / MATLAB, ~~21~~ 20 bytes

*1 byte off thanks to @Yelp!*

```
while printf('A')end

```

Try it online!

### Explanation

`printf('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 an infinite loop.
> 2 votes

# Answer
# AWK, 28 bytes

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

```

Try it online!
> 2 votes

# Answer
# 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!
> 2 votes

# Answer
# BASIC, ~~21~~ ~~18~~ ~~17~~ 13 bytes

```
1?"A";
GOTO 1

```

Try it online!

Everyone's first program!

Credits:

* -3 bytes thx to @ceilingcat
* -1 byte thx to @S.S. Anne
* -3 bytes more thx again to @ceilingcat!
> 2 votes

# Answer
# 05AB1E, 4 bytes

```
['A?

```

Try it online!

```
[         # infinite loop
 'A       # "A"
   ?      # print without a trailing newline

```
> 2 votes

# Answer
# PHP, ~~16~~ 14 bytes

```
for(;;)echo A;

```

Try it online!

* -1 byte thx to @Kaddath!
> 2 votes

# Answer
# , 15 bytes

```
repeat cat('A')

```

Try it online!

Optimized thanks to @S.S. Anne

# Perl 5 (cperl), 17 bytes

```
for(;;){print"A"}

```

Try it online!

Optimized 1 byte thanks to @S.S. Anne

# Squirrel, 17 bytes

```
for(;;)print("A")

```

Try it online!

Optimized 1 byte thanks to @S.S. Anne
> 2 votes

# Answer
# Bash, 11 bytes (10 + 1)

```
printf A;s

```

Try it online!

This script must be saved in file named `s`, and that file must be in a directory in your PATH.

I've added 1 byte to the score to account for the required filename, as per https://codegolf.meta.stackexchange.com/a/1072/59825 .

Of course, this recursively forking script is going to run out of resources very quickly, especially if you try running it on TIO :-) .
> 2 votes

# Answer
# 33, 7 bytes

```
"A"j[p]

```

```
"A"     Put "A" in the source string
   j    Copy the value into the accumulator, so the loop never terminates
    [p] Print infinitely

```

Try it online!
> 2 votes

# Answer
## `j`, 3 bytes

```
'AI

```

## Explanation.

  I % Forever:
'A  % Calculate the string "A"
    % Implicit output

Flag:j % Without a newline
```
</code></pre>
> 2 votes

# Answer
# batch file 36 bytes

```
for /L %%n in (,,)do @ECHO|set/p="A"

```

# batch console 35 bytes

This can be run directly in the windows cmd console.

```
for /L %n in (,,)do @ECHO|set/p="A"

```
* -3 bytes and more thanks to @SomethingDark!
> 2 votes

# Answer
# F# (.NET Core), 22 bytes

```
while 1=1 do printf"A"

```

Try it online!
> 2 votes

# Answer
# Whitespace, 23 bytes

```
[N
S S N
_Create_Label_LOOP][S S S T S S S S S T N
_Push_65_A][T   N
S S _Print_as_character_to_STDOUT][N
S N
N
_Jump_to_Label_LOOP]

```

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

**Explanation in pseudo-code:**

```
Start LOOP:
  Character c = 'A'
  Print c as character to STDOUT
  Go to next iteration of LOOP

```
> 2 votes

# Answer
# Batch, 42 bytes

```
@for /l %%a in (0,0,0) do @set /p="A" <nul

```
> 2 votes

# Answer
# Clojure, 18 bytes

```
(while 1(print\A))

```

Try it online!
> 2 votes

# Answer
# Mumps/Caché, 8 bytes.

`f ?'A';`

Start an infinite loop (f) Print 'A' with no newline (?'A';)
> 2 votes

# Answer
# Vim, 10 bytes

@Noodle9's answer of `qqiA^[@q` is a good start but is incorrect:

The call of macro-q is using any previous setting of macro-q. This only worked because, in testing, they had previously recorded macro-q to output A, so they were unwittingly relying on saved state.

You can see this by trying to change the A to a different letter, and the first time you test it you will still get 'A's. Or you can first clear macro-q with "qqq"

Here is a correct answer along the same lines:

```
qqiA^[@qq@q

qq            Record macro-q (the first time)
  i           Insert
   A          Letter 'A'
    ^[        Exit insert mode
      @q      Call macro-q
        qq    Stop recording
          @q  Call macro-q

```

Although this does require that nothing is in macro-q at the start, which I think is a fair assumption for code golf, that you are starting with a clean slate / fresh install, as opposed to random initialization state. If not, or if you want to test this and have macros set already, you would need to do:

```
qqqqqiA^[@qq@q

```

Where the initial 'qqq' will clear the macro-q.

Of course, all of this is much easier to read if you don't use 'q' for the macro. :)
> 2 votes

# Answer
# **Python 3, 25 22 bytes**

Saved 3 bytes thanks to Jo King! :)

```
while 1:print(end='A')

```
> 2 votes

# Answer
# Kotlin, ~~50~~ 47 bytes

```
fun main(a:Array<String>){while(0<1)print("A")}

```

1.) Thanks to @Adam for pointing out the args naming
> 2 votes

# Answer
# Python 2, 40 bytes

```
import sys
while 1:sys.stdout.write('A')

```

Try it online!

Python 2 prints with either a newline or a space separator but we can import the `sys` module then write to `stdout` to get round this.
> 2 votes

# Answer
# PowerShell ~~27~~ 25 bytes

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

```

Try it online!

`-n` parameter for `Write-Host` works as `-NoNewline`.
> 2 votes

# Answer
# Rabbit~, 5

```
A]:.[

```

Explanation:

```
A - store A to memory (not strictly used as A is already in memory, when loading the program. But the A is overwritten by a new A)
 ] - Start loop, read A as input
  :. - Print A character
    [ - Check current input, which is still A, carry on looping

```

Inverted brackets loops until input is not equal, doesn't terminate since input is always 'A'
> 2 votes

# Answer
# Rail, 17 bytes

```
$'main'
@-[A]o[]@

```

***-*** horizontal rail (a rail is required as entry from starting point ***$***)

***@*** bumper to reverse travel direction

***o*** prints characters between the brackets ***\[ \]***
> 2 votes

# Answer
# MarioLANG, 45 bytes

```
+>+
+"+
+++
+++
++(
++-
+)[
+!<)+>.<
=#======

```

Try it online!

Mario falls down the first column, colecting 8 pluses. He then steps on the elevator and repeats the second and third column 8 times, colecting a total of 64 pluses in his second cell. After that, he adds another plus to that and starts running left and right, screaming "AAAA"
> 2 votes

# Answer
# Hexadecimal Stacking Pseudo-Assembly Language, 30 bytes

```
000000200041400000130000010000

```

Try it online!

```
000000  label Start:
200041  input 0x41 (dec. 65, ASCII 'A')
400000  push that on stack 0
130000  print character from stack 0
010000  jump to Start:

```
> 2 votes

# Answer
# Erlang (escript), 24 bytes

An operand-less function self-recursing, printing the string.

```
a()->io:fwrite("A"),a().

```

Try it online!

## Explanation

```
a()->               % Define a niladic function.
io:fwrite("A")      % Print "A" to the console.
,a().               % After that, call itself again.

```
> 2 votes

# Answer
# Cubix, 4 bytes

```
.'Ao

```

or

```
.o'A

```

Try it online!

***.*** = starting point

***'A*** = literal A

***o*** = prints output

Since Cubix wraps around in a cube surface, it's an infinite loop.
> 2 votes

# Answer
# Stax, 4 bytes

```
W'Ap

```

Run and debug it
> 2 votes

# Answer
# !@#$%^&\*()\_+, 5 bytes

```
A(!@)

```

Try it online!

Very simple. Just push `A`, infinitely dup and print.
> 2 votes

# Answer
# , ~~7~~ ~~6~~ 5 bytes (~~19~~ ~~15~~ 13 characters)

```
1170363757403

```

Try it online!

### Explanation

The main program pushes `**77**03**3**|**5**|**463**` on the frame, and the last section, `**463**`, runs. **`4`** swaps it with the previous section, a single **`5`**, and **`6`** pacifies the **`5`** back into `5`. **`3`** outputs the `5`, specifying output format 5 ("US-TTY"), and deletes the **`463`** section which is now before it.

`**77**03**3**` is left on the frame, and it runs in a loop forever. `**77**03` creates an empty section and a section with `**63**`, which is outputted by **`3`**. `**63**` contains an anonymous command, so it can't be output directly. Instead, it is pacified and **`7`** is added before it, and the resulting string `703` is outputted. In output format 5, `7` is ignored and `03` corresponds to the character `A`, which is printed to STDOUT. The `**77**03**3**` section hasn't been deleted (because we added an empty section to get deleted by **`3`** instead), so it runs again.
> 2 votes

# Answer
# Stax, 3 bytes

```
W"A

```

Run and debug it
> 2 votes

# Answer
# GORBITSA-ROM, 7 bytes

```
S\101TS\000B\000

```

in more readable form:

```
S65 T S0 B0

```

### Explanation

```
S65          load 'A' into register
    T        output it
      S0 B0  jump to the beginning

```
> 2 votes

# Answer
# MAWP 0.1, 8 bytes

```
[94M5W;]

```

Explanation:

```
[          start of loop
94M5W      push 65 to stack ((9+4)*5)
;          print as ascii
]          end of loop

```
> 2 votes

# Answer
# Shakespeare Programming Language, 134 bytes

```
,.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]
Ajax:You is the sum ofthe cube ofa big big cat a cat.Speak thy.Let usAct I.

```

Try it online!

(Newline added for readability.)

The ASCII code for A is 65, which is represented following this trick as \\$65 = (2\cdot 2\cdot 1)^3 +1\\$. Puck will say `A` indefinitely.
> 2 votes

# Answer
# JavaScript, ~~25~~ 34 bytes

```
for(;;){process.stdout.write('A')}

```

Prints 'A' to the console indefinitely.
> 2 votes

# Answer
# Japt, 5 bytes

Assumes infinite memory.

```
ßOoau

```

Test it

```
ßOoau
ß         :Recursive call with (irrelevant) argument
 Oo       :  Output (returns undefined)
   au     :    "a" uppercased

```
> 2 votes

# Answer
# C++ (gcc), 38 bytes

```
#import<ios>
int A(){putchar(65)&A();}

```

Try it online!
> 2 votes

# Answer
# Pyth, 4 bytes

```
#p\A

```

```
#     Infinite Loop
 p    Print with no newline
  \A  Single character string

```

Try it online!
> 2 votes

# Answer
# Forth (gforth), ~~21~~ 18 bytes

```
: f ." A"recurse ;

```

Try it online!

Although Forth typically tokenizes entirely by splitting on whitespace, as symbols and the like are allowed anywhere within a word, the word `."` causes a string to be parsed up until a closing quote without also trying to parse that closing quote as part of a word.

I'm so unaccustomed to golfing in relatively ordinary languages that I forgot I could submit a named function!

Overflows the return stack quite quickly, and `: f ." A"r> recurse ;` doesn't take much longer to overflow the *data* stack, so without the assumption of infinite memory:

# Forth (gforth), ~~25~~ ~~22~~ 20 bytes

```
[begin] ." A"[again]

```

Try it online!

*-2 thanks to Bubbler*
> 2 votes

# Answer
# Add++, 10 bytes

```
x:"A"
Wx,o

```

Try it online!

First, we set `x` to `A`. A non-empty string is evaluated as true, so the `W`hile loop runs. `o` outputs the active variable, which is `x`, without a newline.
> 2 votes

# Answer
# convey, 4 bytes

```
'A'}

```

Try it online!

An interesting (often annoying, but sometimes interesting) feature of convey is that string or number literals will output forever. So this outputs A constantly...
> 2 votes

# Answer
# Factor, 19 bytes

```
[ "A"write t ] loop

```

Try it online!

`loop` looks at the top of the stack and performs another iteration if it finds `t`. This is 1 byte shorter than using `forever`.
> 2 votes

# Answer
# Written in Ark, 8 bytes

`{~ !A }~`
> 2 votes

# Answer
# Perl 5 (ppencode), ~~35~~ 33 bytes

```
print uc chr ord qw s abs while x

```

Try it online!

## Previous

```
print uc chr ord qw s abs while exp

```

Try it online!

Alternatively:

```
print uc chr ord qw s abs while cos

```
> 2 votes

# Answer
# Minim, 10 Bytes

```
$<65.C=-1.

```

With whitespace and comments:

```
$< 65.  ; Print 65 as unicode 'A'
C = -1. ; Set program counter to -1 (advances to 0 afterwards)

```

GitHub Repository
> 2 votes

# Answer
## Swift, 35 bytes

```
while 1>0{print("A",terminator:"")}

```

Try It Online cuts it off after 128kiB of output, but this will run forever. Swift `for` loops are Python-like, not C-like, so those aren't any help here.

This is my first code golf for something other than Arduino.
> 2 votes

# Answer
# Vim, 9 bytes

```
qqA<C-r>q<C-o>q<C-r>q

```

Uses the same Recursive Register Expansion trick as my Lolololololololololololol answer, inserting the unnamed register, which contains 'A' + the unnamed register. To see the output, you'll have to try it in Vim, and you may need to use `Ctrl`+`C` to stop the expansion if the terminal freezes.

Try it online!
> 2 votes

# Answer
# Lexurgy, 17 bytes

```
a propagate:
*=>A

```

Forever replaces an empty string with `A`.
> 2 votes

# Answer
# Piet, 15 Codels:

Original(5x3):

Scaled (x20):

Operations in each loop:

```
push 8
dup
*
push 1
+
out(char) ;outputs 65 as 'A'

```

After each cycle, the index will flow through the white codel on the bottom left and repeat another cycle, running indefinitely.

Try it online!
> 2 votes

# Answer
# Rust, 17 bytes

```
loop{print!("A")}

```

Try it online!

Not much of a golfing language, but I love the `loop` keyword.
> 2 votes

# Answer
# Emmental, 20 bytes

```
;#58#46#35#63#!#65#?

```

Try it online!

## How?

```
;#58#46#35#63#!#65#?
;                     push ';' onto the stack
 #58#46#35#63         push ":.#?" onto the stack
             #        push NULL onto the stack
              !       pop NULL, ":.#?", and ';', and make NULL mean ":.#?"
               #65    push 'A' onto the stack
                  #   push NULL onto the stack
                   ?  execute NULL

```

```
:.#?
:    duplicate 'A'
 .   pop and print 'A'
  #  push NULL onto stack
   ? execute NULL

```
> 2 votes

# Answer
# Flobnar, 7 bytes

```
g,_@
1A

```

Try it online!

It is most space-efficient to grab A from code than to try to evaluate from single-digit numbers.

```
@       Evaluate to west
_       If the other side (west) is 0, evaluate to east:
,         Print as char and return 0:
g         Grab code at (1,1) which is 'A' (so A is printed)
1
_       The return value is 0, so evaluate to east,
        which is start of the program again (which also acts as <)
        so it is an infinite loop printing 'A' repeatedly

```
> 2 votes

# Answer
# Nibbles, 2.5 bytes (5 nibbles)

```
^~"A"

```

```
^       # replicate
  "A"   # the letter "A"
 ~      # infinitely

```
> 2 votes

# Answer
# Trilangle, 4 bytes

This version has constant memory usage.

```
"A,o

```

Try it on the online interpreter!

Push an `A`, print it and pop it. For lack of an explicit exit instruction `@`, this loops infinitely by default.

## Trilangle, 3 bytes

This version's memory usage grows without bound.

```
"Ao

```
> 2 votes

# Answer
# \>\<\> (Fish), 4 bytes

```
5d*o

```

Try it

or

```
"A"o

```
> 2 votes

# Answer
# C++ (gcc), 49 bytes

```
#import<iostream>
int A(){for(;;)std::cout<<'A';}

```

Uses C++ I/O.

Try it online!

# C++ (gcc), 41 bytes

```
#import<ios>
int A(){for(;;)printf("A");}

```

Uses C I/O.

Try it online!
> 1 votes

# Answer
# dc, 9

```
[65Pdx]dx

```

### Explanation

```
[     ]   # Push a macro to the stack
 65       # Push the number 65 to the stack
   P      # Pop and print ASCII char 65 (i.e. "A") with no newline
    d     # Duplicate the macro
     x    # Pop and execute the macro at the top-of-stack (tail recursion)
       d  # Duplicate the macro
        x # Pop and execute the macro at the top-of-stack

```

Try it online!
> 1 votes

# Answer
## VisiCalc, 3 bytes

You need an extra newline to enter the instruction. It's a modification of this solution.

```
/-A

```

The trailing newline is significant.

## Explanation

<pre><code>/   Start a command:
 -  Replicate forever
  A The target for replication is the / character
Extra newline to enter the instruction

You end up with a cell with an infinite number of A's.
However, the current cell can only show a finite amount
of A's because cells are trunctuated based on their lengths.
```

> 1 votes

# Answer
# MathGolf, 6 bytes

```
1É'Aq↑

```

Try it online.

Or

```
æ'A_q▲

```

Try it online.

**Explanation:**

```
1       # Push a 1
     ↑  # While true without popping,
 É      # using the following 3 commands:
  'A   '#  Push an "A"
    q   #  Pop and print it without trailing newline

     ▲  # Do while true with pop,
æ       # using the following 4 commands:
 'A    '#  Push an "A"
   _    #  Duplicate this "A"
    q   #  Pop and print it without trailing newline

```
> 1 votes

# Answer
# Befunge-98 (FBBI), 3 bytes

```
'A,

```

Try it online!

`'` pushes the next character to the stack, `,` prints a char.
> 1 votes

# Answer
# JavaScript (Node.js), ~~33~~ 32 bytes

```
for(;;)process.stdout.write('A')

```

Try it online!

-1 byte thanks to Maria Miller
> 1 votes

# Answer
# C# (Visual C# Interactive Compiler), ~~21~~ 18 bytes

```
for(;;)Write('A');

```

Try it online!
> 1 votes

# Answer
# Lua, 27 bytes

```
while 1 do io.write("A")end

```

Try it online!
> 1 votes

# Answer
# Julia 1.0, 17 bytes

```
f()=print('A')f()

```

Try it online!
> 1 votes

# Answer
# Bash, 14 bytes

```
yes A|tr -cd A

```

will very quickly output A's.
> 1 votes

# Answer
# Rust, 17 bytes

```
loop{print!("A")}

```

Try it online!
> 1 votes

# Answer
# Red - 16 bytes

```
forever[prin 'A]

```
> 1 votes

# Answer
# perl -l101 -E, 12 bytes

```
{print;redo}

```
> 1 votes

# Answer
## **ColdFusion**, 32 bytes

```
<cfloop condition="1">A</cfloop>

```
> 1 votes

# Answer
# , 15 bytes

```
3.6006580050094

```

***3.*** start of code

***6*** assigns to cell ***00*** the value ***65***

***8*** starts the loop, keeps running while cell ***00*** is not zero.

***5*** prints ASCII character of the cell ***00***

***9*** closes the loop

***4*** end of code
> 1 votes

# Answer
Kenbark-1 (first personal computer) 6/7 bytes

```
002:
024 X
004 PC
234 200 Print A from X
343 004 jump back to begin of the program

```

Register X is on Address 002 (oct) Then we set program Counter (address 003) to 004 for starting code. Move value from X (024='A') to output register what is set of lights on device front (Address 200 oct). And unconditional jump back to address 004.

User will see steady light, but in reality computer still output A

I'm not sure how to count bytes since that `002:` is needed to tell computer what part of memory we need to fill.

Try it by yourself: http://www.neocomputer.org/kenbak/kenbak1-JS.html
> 1 votes

# Answer
# \*\>\<\>, 4 bytes

```
"A"o

```

Try it online!

Pushes `A` then prints it an infinite amount of times
> 1 votes

# Answer
# Ahead, 5 bytes

```
~oA'~

```

Try it online!
> 1 votes

# Answer
# Brachylog, 4 bytes

```
Ṇhw↰

```

Try it online!
> 1 votes

# Answer
# Brainetry `--live-output`, 59 bytes

This uses the `--live-output` flag otherwise output would be deferred until the end of the program, which would never happen because the program doesn't end.

```
a b c d e f
a b c d e f g h
a b c d e f g
a b c d e f g h i

```

Golfed version of the following code:

```
This program will ask you for
some input but I really only care about
the first character of input. I'm gonna
take such a character and output it MANY times.

```

To try this, clone this GH repo and run `python brainetry.py btry/scream.btry` and give it `A` as input.
> 1 votes

# Answer
# FEU, 18 bytes

```
a/A
loop
print
end

```

Try it online!

## Explanation

```
a/A

```

Append A to the empty input.

```
loop
print
end

```

Starts an infinite loop where you print the input.
> 1 votes

# Answer
# Japt, 10 bytes

```
{Oo'A}g1/0

```

Try it online!

## Explanation

```
{Oo'A}a
{          // Function
 Oo'A      //    Output 'A'
     }     // End Function
      g1/0 // Call infinite times
           // (Japt's O.o() method returns undefined)

```

---

# Japt, 7 bytes

As pointed out by @Shaggy due to how `a` is implemented this will print `A` only `1e8` times

```
{Oo'A}a

```

Try it online!

## Explanation

```
{Oo'A}a
{       // Function
 Oo'A   //    Output 'A'
     }  // End Function
      a // Call repeatedly until it returns a truthy value
        // (Japt's O.o() method returns undefined)

```
> 1 votes

# Answer
# StupidStackLanguage, 11 bytes

```
avqviiimtfu

```

Try it online!

## Explanation

```
a - push 0 to stack
v - add 5
q - duplicate
viii - add 8 (making 13)
m - multiply top 2 items (13x5 = 65)
t - start bf style loop
f - print character
u - end bf style loop

```
> 1 votes

# Answer
# Scala, 20 bytes

```
while(print('A')!=0)

```
> 1 votes

# Answer
# CJam, 7 bytes

```
'A{_o}h

```

CJam loops are surprisingly expensive as there are no markers, and since there's no infinite loop function, we need to make sure there's always a spare truthy A on the stack for our do-while loop.

Try it online

Explanation:

```
'A        Push 'A' to the stack
  {  }h   Loop while top of stack is true
   _      Duplicate the A
    o     Pop and output the A w/ no newline

```
> 1 votes

# Answer
# Oak, 29 Bytes

```
fn main(){while(1){prc!(65)}}

```

This may have to be changed to `fn main(){while(1){prc!('A')}}` once num and char are no longer interchangable, but for now it works.
> 1 votes

# Answer
# Perl 6, 16 bytes

```
loop {print "A"}

```

Try it online!
> 1 votes

# Answer
# Neim, 5 bytes

```
ͻ    # Infinite loop
 (   # Decompress base 255
  A  # A
 )   #
   B # Compress number to base 255

```

Runs only 6 times

Try It Online!
> 1 votes

# Answer
### **x86 machine code - 14 bytes**

So, yeah I'm using `write()` system call to print `A` characters without `\n`

```
     6                                  scream:
     7 00000000 6A41                      push 0x41
     8 00000002 31DB                      xor ebx, ebx
     9 00000004 89E1                      mov ecx, esp
    10 00000006 B201                      mov dl, 0x1
    11 00000008 B004                      mov al, 0x4
    12 0000000A CD80                      int 0x80
    13 0000000C EBF2                      jmp scream

```

This is output using `strace` :

```
write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
<repeat> ..

```
> 1 votes

# Answer
# Husk, 3 bytes

```
∞'A

```

Try it online! Creates an infinite list of `'A` characters and prints it.
> 1 votes

# Answer
# C#, 62 bytes

```
class P{static void Main(){for(;;)System.Console.Write('A');}}

```
> 1 votes

# Answer
# Deadfish~, 4014 bytes:

```
{iiiiii}iiiii{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{c}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

```

Sets the accumulator to 65, then prints as character 102000 times = far beyond the lifespan of the universe.

There's no way to do anything infinitely in Deadfish~, so 102000 times should be enough.
> 1 votes

# Answer
# VBScript, 31 bytes

```
Do
WScript.StdOut.Write("A")
Loop

```
> 1 votes

# Answer
# C# 9, 33

```
for(;;)System.Console.Write('A');

```
> 1 votes

# Answer
# Barrel, 9 bytes (or 8 with newer instruction)

```
^A¤p←1

```

Explanation:

```
^A     // Sets the accumulator to the ASCII codepoint of 'A'.
  ¤ ←1 // Creates a jump target and jumps back to it.
   p   // Prints the accumulator as a character value.

```

Since the  command will implicitly push the current location onto the location pointer stack, this program will use lots of system memory. In fact, on my system it used about one megabyte of RAM per second. To overcome this, I've since implemented the  operator, which jumps without pushing (and therefore removes the possibility of RAM overflow). It makes the command look like this: `^A¤p↰1`

This could be 8 bytes now that I have implemented the infinite loop that I'd thought about implementing: `^65#∞p` In this case, the `#∞p` would define a loop which would print the character value infinitely. However, since the infinity command may have been inspired by this (I actually forget) and the command is newer than the answer anyway, I'll refrain from changing my answer.
> 1 votes

# Answer
# A0A0, 44 40 bytes

```
A0A0
A0C3G1G1A0
A0P65A0
A0A1G-3G-3A0
G-3

```

Forms a standard infinite loop, with the three actual instructions to be executed in the middle.

```
P65 ; prints 'A'

```

Edit: Optimize by 4 bytes. The loop does not need three instructions to function, so we can drop two instructions, totalling four bytes.
> 1 votes

# Answer
# Ruby, 12 bytes

```
loop{$><<?A}

```

Try it online!

---

# Explanation

```
loop {...} //infinite loop
$> //synonym for STDOUT
<<?A // << appends an element and ?A is shorthand for 'A'

```
> 1 votes

# Answer
# Fortran, ~~50~~ 49 bytes

```
program A
do
write(*,"(A)",advance="no")"A"
enddo
end

```

Try it online!
> 1 votes

# Answer
# Mascarpone, 11 bytes

```
['A.:!]v*:!
[   :!]v*:!  // infinite loop
 'A.         // with the side effect of outputting 'A' each iteration

```

I feel a bit scummy for reposting the same code to multiple questions, but I guess it has to be done.
> 1 votes

# Answer
# Regenerate `-as ''`, 2 bytes

```
A+

```

Try it here!

With the `-a` flag, Regenerate outputs all strings that match the given regex. With the `-s` flag setting the separator to `''`, it outputs them with no separator. The output with a newline separator would look like...

```
A
AA
AAA

```

... but with an empty separator, it's just an unending stream of `A`.
> 1 votes

# Answer
# Nim, ~~26~~, 25 bytes (Credits to @hyper-neutrino)

```
while 1>0:stdout.write'A'

```

Try it online!

Not great, but not too shabby.
> 1 votes

# Answer
# Daoyu, 13 instructions, 7 bytes

There's two! Each instruction is a hex, so two instructions fit in a byte.

```
$$$(([]!)/(/[]!)):><
OPLEV 0:
$$$                   Allocate 8 bits of memory to the bit tape
   (([]!)/(/[]!))     Set the bit tape to 01000001
                 :><  Print the bit tape, and loop to the beginning
OPLEV 1:
...                   NOP
   ((().)/(/().))     Moves around the bit tape with no effect
                 :><  Print the bit tape, and loop to the beginning

```

This one is simpler, but it's 20 instructions and an extra byte. The first time the program loops, the operation level is 0, and it runs the first program, which allocates memory, sets the bit tape to 'A', and prints. Every other time it loops it just prints the bit tape.

```
%!)))):((((><
%!             Acts as NOP, encodes 'A'
  ))))         Moves data reader to '%!'/'A'
      :((((><  Prints, resets position, and loops to beginning

```

This one reads its own source code, and is a few bytes smaller. The operation level does change, but it doesn't really affect any of the program. When attempting to `MERGE` (`)`) while selecting the entire but tape, which is the original state of the program, the data reader moves to the parent bit tape, which is the program's source code. The program navigates to the `%!`, prints it as `'A'`, and loops.
> 1 votes

# Answer
# Rattle, 7 bytes

```
65|[,]0

```

Try it Online!

# Explanation

```
65|             hard-coded input (Rattle's equivalent to a variable declaration)
   [...]0       infinite loop
     ,          prints the ASCII character of the value on top of the stack (A = ASCII 65)

```
> 1 votes

# Answer
# JavaScript (Node.js), ~~33~~ 32 bytes

-1 byte thanks to @Luke\_

```
for(;;)process.stdout.write('A')

```

Try it online!
> 1 votes

# Answer
# Deorst, 6 bytes

```
oA
#EO

```

Try it online!

Explanation:

```
oA   # Push 'A'
#    # Forever:
 EO  #   Print without newline

```
> 1 votes

# Answer
# WedgeScript, 4 bytes

```
'A|o

```

Explanation:

```
'A    Pushes the character literal A to the stack\
|     Loop the rest of the code infinitely\
o     Output

```

Yes, Wedgescript is a custom language made by me, here is the repo with interpreter install instructions: https://github.com/WedgeScript/WedgeScript
> 1 votes

# Answer
## Arduino, 63 bytes

```
void setup(){Serial.begin(300);}void loop(){Serial.write('A');}

```

Not sure how much explaining I need to do here. Arduino has an infinite loop built-in, so just write one `'A'` to the Serial output inside of it. Equally valid would be `Serial.print('A');` and `Serial.print("A");`, and I think `Serial.write("A");` should work as well. It's all just a matter of preference.
> 1 votes

# Answer
# Vyxal, 4 bytes

The try it link has the `5` flag to prevent it from freezing up forever.

```
{\A₴

```

## Explanation

```
{    - While loop
 \A  - Push "A"
   ₴ - Print without newline

```

Try it Online!
> 1 votes

# Answer
# INTERCAL (C-INTERCAL), 61 bytes

```
DO,1<-#9DO,1SUB#1<-#126DOCOMEFROM#9PLEASEREADOUT,1(9)DO,1<-#9

```

Try it online!
> 1 votes

# Answer
# CLC-INTERCAL, 48 bytes.

```
DO;1<-#1DO;1SUB#1<-#20DOCOMEFROM#9(9)DOREADOUT;1

```

(Don't) Copy and paste to try it online! It is very recommend to replace COME with NEXT, as output suppression may be weak.
> 1 votes

# Answer
# ErrLess, 3 bytes

```
'A?

```

## Explanation

```
'A { Push 'A' to the stack }
?  { Output the top element of the stack as a character }

```

The Instruction pointer loops when it reaches the end of the program.

Try it online!
> 1 votes

# Answer
# Python 3, 23 bytes

```
while[print(end="A")]:0

```

Try it online!
> 1 votes

# Answer
## Desmos with actions, 44 bytes

Code in ticker:

```
s_{tdout}\to join(s_{tdout},65)

```

Code in list (the actual area where you can enter equations):

```
s_{tdout}=[]

```

It outputs the ascii code for `A`

Link: https://www.desmos.com/calculator/u1fynzwbuf
> 1 votes

# Answer
# Underload, 10 bytes

```
((A)S:^):^

```

Try it online!

Explained:

```
(    :^):^ While true...
    S      Print
 (A)       The string "A"

```
> 1 votes

# Answer
# makina, 14 bytes

```
>Pv
^>OtA;
^<<

```
> 1 votes

# Answer
# rusty\_deque, 19 bytes

```
'A'~{dup~ow~}~loop~

```

Pretty much a duplicate of my "Shortest code to produce infinite output" answer.
> 1 votes

# Answer
# Fig, \\$4\log\_{256}(96)\approx\\$ 3.292 bytes

```
(;/A

```

See the README to see how to run this

```
(;/A # Takes no input, obviously. Tbh I have no idea what to write on the first comment line
(    # Repeat forever:
 ;   # Print
  /A # "A"

```
> 1 votes

# Answer
# Prolog (SWI), 18 bytes

```
a:-put(65),a.
?-a.

```

Try it online!

-1 from Steffan.
> 1 votes

# Answer
# yup, ~~33~~ 31 bytes

```
0eee:0~--:0~--0:ee-0ee--0e-{:@}

```

Pushing the `65` can perhaps be shortened.

Try it online.

**Explanation:**

yup has a limited amount of operators, so almost everything in the program is to push 65:

```
0        # Push a 0
 e       # exp(0) = 1
  e      # exp(1) = 2.718...
   ::    # Duplicate this 2.718... twice
     ]]  # Rotate them both to the bottom of the stack
       e # exp(2.718...) = 15.154...
:        # Duplicate this 15.154...
 0       # Push another 0
  ~      # Reverse the top two values
   -     # Subtract them: 0-15.154... = -15.154...
    -    # Subtract again: 15.154...--15.154... = 30.308...
:0~--    # Do the same: 30.308...--30.308... = 60.617...
0        # Push 0 again
 [       # Rotate a 2.718... back to the top of the stack
  -      # Subtract: 0-2.718... = -2.718...
   [     # Rotate the other 2.718... to the top
    -    # Subtract again: -2.718-2.718 = -5.436...
     -   # Subtract it: 60.617...--5.436 = 66.053...
0e-      # Push and subtract 1: 66.053...-1 = 65.053...

{  }     # Loop while the top of the stack is NOT 0:
 :       #  Duplicate the 65.053...
  @      #  Print it as character with this codepoint, where yup implicitly rounds
         #  decimals to their nearest integers when it needs an integer

```
> 1 votes

# Answer
# GolfScript, 13 bytes

```
{"A".print}do

```

Try it online!
> 1 votes

# Answer
# Thunno, \\$ 5 \log\_{256}(96) \approx \\$ 4.12 bytes

```
['AZL

```

Attempt This Online!

#### Explanation

```
[       # while True:
   ZL   #  print with no newline:
 'A     #   "A"

```
> 1 votes

# Answer
# Pip, 7 bytes

```
W1{O'A}

```

Attempt This Online!

#### Explanation

```
W1{   }  # while 1:
   O'A   #  print "A" without a trailing newline

```
> 1 votes

# Answer
# Byte-based Instruction Jumping, 2 bytes

```
↓A

```

is a simply a placeholder for a non-printable ASCII character, so it takes a single byte of space. It evaluates to the following instructions:

```
mvr ... ... wrt cns ... ... mvl

```

It moves the instruction pointer to the byte on the right side of the current one (`mvr`), which is `A`, then writes it (`wrt`) to the console (`cns`) and moves back left (`mvl`). Now, the instruction pointer points to the first byte again, and executes the same instruction over and over forever.
> 1 votes

# Answer
# JavaScript, 38 bytes

```
setInterval(()=>document.write("A"),4)
```
Wow, I did not expect JS would be that uncooperative! (`setInterval(document.write,4,"A")`) errors, but I guess that's screaming in a different way.
> 1 votes

# Answer
# Racket, 25 bytes (10 brackets)

```
(let a()((print 'a)(a)))

```
> 1 votes

# Answer
# Swift, ~~36~~ 35 bytes

```
while 1<2{print("A",terminator:"")}

```

Try it online!

* Golfed 1 byte by reducing condition length
> 1 votes

# Answer
## Pascal, 51 bytes

This is a complete program according to ISO Standard 7185 "Standard Pascal". You may interpret it as a script, the standard does not prescribe or set restrictions to that.

```
PROGRAM A(OUTPUT);BEGIN WHILE 8=8 DO WRITE('A')END.

```
> 1 votes

# Answer
# Commodore C64/VIC-20/C16/+4/C128 (using Kernal) 7 bytes

This is the assembled code at memory location 828 (some free RAM usually used as the Datasette buffer):

```
.033c a9 41 20 d2 ff d0 f9

```

Or in 6502 assembly:

```
* = 828
    lda #$41
    jsr $ffd2
    bne $033c

```

We can use a relative branch here (`bne $033c`) instead of a jump instruction, which saves one byte. The branch is conditional, but the condition is never set (it compares against the zero flag, and as the accumulator is set to a non-zero value, this condition is never met).

The `lda #$41` loads the accumulator with the value 65, which is the letter A in PETSCII, and `jsr $ffd2` calls to the CHROUT Kernal routine. This will translate the value on the accumulator register to a character code, and output to the default output device, which will be the screen in this instance. So the character `A` is outputted until the machine is reset.
> 1 votes

# Answer
# YASEPL, 6 bytes

```
#"A"?1

```

very simple. :3
> 1 votes

# Answer
# Rust, 34 28 bytes

```
fn main(){loop{print!("A")}}

```

Try it online!

Thank you for emanresu A for suggesting using `loop` and correcting my code!
> 1 votes

# Answer
# Duocentehexaquinquagesimal, 8 bytes

```
2ïÛ∞è¥₁Ú

```

Try it online!
> 0 votes

# Answer
# Kotlin, 32 bytes

```
fun main(){while(0<1)print('A')}

```

Try it online!
> 0 votes

# Answer
# Splinter, 7 bytes

```
A{\AA}A

```

Try it online!

Interpreter breaking version. Would run forever otherwise.
> 0 votes

# Answer
# BRASCA, 5 bytes

```
1[Do]

```

Try it online!

## Explanation

```
1[  ] - Loop infinitely:
  Do  - Push "A" and output

```
> 0 votes

# Answer
# Batch 17 bytes

```
@Set/P=A<nul
@%0

```

Explanation:

* `@Set/P=A<nul` : Output A without newline
* `@%0` : Loop by restarting the script
> 0 votes

# Answer
# !@#$%^&\*()\_+, 5 bytes

```
A(!@)

```

Try it online!

```
A   # Push A to the stack
(   # Start while loop
 !  # Duplicate top of stack
 @  # Print top of stack
)   # End while loop

```

Because top of stack is always truthy, it never ends.
> 0 votes

# Answer
# 2D Deadfish, 23 bytes

```
>~{i}ddsicv
^         <

```

Try it online!
> 0 votes

# Answer
# Knight, 7 bytes

```
W1O"A\"

```

Try it online!

```
# infinite loop
WHILE 1
   # Output "A". The backslash disables
   # the implicit newline.
   OUTPUT("A\")

```
> 0 votes

# Answer
# MMIXAL, 51 bytes

```
 LOC 0
Main SET $255,12
 TRAP 1793
 JMP 0
 BYTE 65

```

Surprisingly, this is one byte shorter than the minimal assembled version.

Explanation:

```
 LOC 0                  // start at 0; I believe this is required
                        // if it's not, we can drop 7 bytes
                        // (and possibly 8 from assembled version).
Main SET $255,12        // execution starts here
 TRAP 1793              // fputs(stdout, $255)
 JMP 0                  // jump back to address 0
 BYTE 65                // 'a' at address 12; any unset byte is 0.

```
> 0 votes

# Answer
# \<\>^v, 14 bytes

```
"A">~v
   ^ <

```
> 0 votes

# Answer
# Underload, 10 bytes

```
((A)S:^):^

```

`(A)S:^` is pushed onto the stack, and after the first duplication and evaluation, it repeatedly evaluates itself, printing 'A' infinitely.

(I didn't find any other Underload answers, but if I missed one I'll delete this)
> 0 votes

# Answer
# FALSE, 9 bytes

```
[1]['A,]#

```

Try it online!

## Pseudo-Code

```
While 1:
  Print "A"

```

Note: On TIO the interpreter throws an error. However, the code isn't erroneous. To show this, I ran it on another interpreter, which can be found at the link below:

http://morphett.info/false/false.html
> 0 votes

# Answer
# KonamiCode, 25 bytes

`v(^^^^^^>^^^^^)L(>)<<B(>)`

Fortunately 65 != 0, so we can cheat a bit and use it as our "counter".
> 0 votes

# Answer
# Haifuckqueue, 21 bytes

```
#{A}o
$1|1.1o
ooooo

```

***Don't try it online!***

It turns out the server set up by the language's author has no timeout, so it's currently printing millions of A to STDOUT with no sign of stopping. Instead, download and run the intepreter and you should get something like this:

# Explanation

The `o` are NOPS (effectively, they're actually xor), so the actual code is simply

```
#{A}
$1|1.1

```

`#` \- pop the stack
`{A}` \- push an `A`
`$1` \- pop and print the ToS
`|1` \- Push 1
`.1` \- Jump to line 1 (First line)
> 0 votes

# Answer
# JavaScript, 32 bytes

```
for(;;)process.stdout.write("A")

```

`for(;;)` is one byte shorter than `while(1)`
> 0 votes

# Answer
# Python 3, 34 bytes

```
def f(n=9):print(end="A"*n);f(-~n)

```

Try it online!

Trying to print as many `A`s as possible with recursion.
> 0 votes

# Answer
## Come Here, 22 bytes

```
COME FROM1 1TELL65NEXT

```
> 0 votes

# Answer
# Befunge-93, 4 bytes

```
"A",

```

Try it online!
> 0 votes

# Answer
# Ruby, 14 bytes

```
loop{print"A"}
```

Attempt This Online!
> 0 votes

# Answer
# AMD64 Bare Metal, 512 bytes

```
mov ah, 0x0e
mov al, 'A'
loop:
int 0x10
jmp loop
times 510-($-$$) db 0
db 0x55
db 0xaa

```
> 0 votes

# Answer
# Cognate, 17 bytes

```
F Def F(F Put"A")

```

Attempt This Online!

# Cognate, 19 bytes

```
While(True)(Put"A")

```

Attempt This Online!
> 0 votes

# Answer
# Arturo, 17 bytes

```
f:$=>[prints"A"f]

```

Try it
> 0 votes

# Answer
# Grass, 106 bytes

```
wwWWwWWWwvwWWwwwwWwwwwwwWWWWwwWWWWWwWwwwWWWWWWWwwWWWWWWWWwWWWWWWWWWwWwwwwWWWWWWWWWWWwwWwwvwWWwWWWWWwWWWwww

```

Try it online!

Grass is pretty difficult to follow, so I'll try to break things down as best as I can.

The first function, `wwWWwWWWwv`, takes in two parameters, a function and a character. It essentially just performs the given function on the character twice.

The second function creates the character `A`. Getting there is a little complicated, since the only character we initially have to work with is `w`. This means we have to call the primitive succession function 202 times. To accomplish this, we use the first function to recursively call succession several times. I've put what's currently at the top of the stack after each instruction.

```
w
WWwwww           (Succession Function x2)
Wwwwwww          (Last character +2)
WWWWww           (Succession Function x4)
WWWWWw           (Succession Function x8)
Wwww             (Last character +8)
WWWWWWWww        (Succession Function x16)
WWWWWWWWw        (Succession Function x32)
WWWWWWWWWw       (Succession Function x64)
Wwwww            (Last character +64)
WWWWWWWWWWWww    (Succession Function x128)
Www              (Last character +128)
v

```

The third and final function, `wWWwWWWWWwWWWwww`, is our main function, which calls the second function, prints its resulting `A`, and recursively calls itself.
> 0 votes

# Answer
# brainfuck, 17 bytes

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

```

Try it online!

**Explaination**

```
>+[+[<]>>+<+]>     make the number 65
              [.]  print it until it equals 0 (i.e. never)

```
> 0 votes

# Answer
# Uiua, 9 bytes

```
⍥(&pf@A)∞

```

Try it!

```
⍥(&pf@A)∞
⍥(     )∞  # repeat (...) forever
     @A    # the letter A
  &pf      # print w/o newline

```
> 0 votes

# Answer
# uxn/vavara, 8 bytes

Compiled machine code:

```
00000000: 8041 8018 1740 fff8                      .A...@..

```

Source (in uxntal):

```
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1

|0100 @on-reset ( -> )
    ( push a, the .Console/write port, output to device, then jump back to on-reset )
    LIT "A .Console/write DEO !on-reset

```

I think for this language the binary size should count since uxntal is basically just assembly for the uxn system
> 0 votes

# Answer
# ByT, 29 bytes

```
main = 1 main 0 1 0 0 0 0 0 1

```

In this language the output is only printed after the program halts, so to print infinitely many `A`s the program must halt with an infinite string in the stack. This program halts by trying to execute a `0` command that doesn't have enough arguments:

```
bar baz 0
    where
        foo = 1 main
        bar = foo 0
        baz = 0 0

```

In this situation `baz` is deleted and the final output is the string represented by `bar`, which is defined as: (using Haskell notation)

```
bar_str = "0" ++ foo_str
    where
        foo_str = main_str ++ "1"
        main_str = "10000010" ++ main_str ++ "1"

```

`bar_str` ends up being the bits `010000010100000101000001...`, the same as `AAA...`, and this is printed to stdout.

This program turns out to be optimal. A `main` stack is required for compilation, so `main =` can't be golfed. An infinite string is also necessary and the only way of doing this is through recursion in the `main` stack, this string must also repeat some rotation of the bits `01000001`, so they must be in the definition of `main` and therefore `main 0 1 0 0 0 0 0 1` can't be golfed either. The only possible optimization would be removing the left most `1`, but none of the eight possible 27 bit solutions work:

```
main = main 1 0 0 0 0 0 1 0     // prints nothing
main = main 0 1 0 0 0 0 0 1     // prints nothing
main = main 1 0 1 0 0 0 0 0     // prints nothing
main = main 0 1 0 1 0 0 0 0     // loops
main = main 0 0 1 0 1 0 0 0     // prints nothing
main = main 0 0 0 1 0 1 0 0     // prints nothing
main = main 0 0 0 0 1 0 1 0     // loops
main = main 0 0 0 0 0 1 0 1     // prints nothing

```
> 0 votes

---
Tags: code-golf, string
---


title: Drawing a cube in ASCII art

text:
# Question
Title: Drawing a cube in ASCII art
**Task description:**

Draw a cube in ASCII art in roughly a cabinet projection.

`Monospaced fonts` often have characters that are about twice as high as they are wide. Since the input is the length of the vertical lines (excluding the corners), horizontal lines are drawn with twice as many characters so that the resulting image is really roughly a cube. The receding lines are drawn at half the length as mandated by a cabinet projection.

Corners of the cube are represented by `+`, horizontal lines by `-`, vertical lines by `|` and diagonal ones use `/`.

Summarizing: Let the input be *n*, then

* A horizontal edge of the cube are drawn with `-` and consists of 2 *n* characters.
* A vertical edge of the cube are drawn with `|` and consists of *n* characters.
* A diagonal edge of the cube are drawn with `/` and consists of *n*/2 characters.
* Corners of the cube are drawn with `+`. Corners are not counted for the length of an edge as detailed above (see examples below as well).

**Input:**

The input, given on standard input, is a single positive, even number *n* (2 ≤ *n* ≤ 30) that gives the length of the vertical lines of the cube. It is followed by a single line break.

**Output:**

The output is a cube on standard output following above rules. Trailing whitespace on the lines is ignored.

**Sample input 1:**

```
2

```

**Sample output 1:**

```
  +----+
 /    /|
+----+ |
|    | +
|    |/
+----+

```

**Sample input 2:**

```
4

```

**Sample output 2:**

```
   +--------+
  /        /|
 /        / |
+--------+  |
|        |  |
|        |  +
|        | /
|        |/
+--------+

```

**ETA:** I now accepted the shortest solution. I will update the accepted answer when a shorter one comes along.

Since some people asked how long the entries of our contestants were:

> 227 – Python
> 240 – Perl
> 310 – C
> 315 – C
> 326 – VB.NET
> 459 – C

As well as our own solutions (not ranked with the others):

> 140 – Golfscript
> 172 – Ruby
> 183 – PowerShell

# Answer
> 10 votes
## Golfscript - 96 chars

```
~:<2/:$){' '*}:s~'++'<'--'**:^n$,{.$\-s'//'2s<*:&*@s'|':|n}%^$[$s|n|&|]*$s'+'n$,{n'/'@s|&|}%-1%^

```

Most of the compactness comes from aggressively storing almost everything to a variable (unless you include being written in golfscript).

```
<    n
$    n/2
s    {' '*}     # top of the stack becomes a string of that many spaces
^    '+------+'
&    '      '   # 2n spaces, i.e. 2s<* or <s2*
|    '|'

```

A couple of other small tricks here.

1. `'LR''str'*` -\> `'LstrR'`.
2. Since we need to reverse the order of lines in the last array, we opt to do this after generating the text instead of before. This allows us to save one character because the spaces before the `'/'` only needs to go past two stack elements (`@`) instead of 3 (`@ .. \`).

# Answer
> 17 votes
## Python - 248 243 230 227 191

Slightly messy but it basically prints the cube line by line(using a string buffer).

```
t=v=h=input()/2
s,p,b,f,n=" +|/\n"
l=p+"-"*t*4+p;S=s*4*t;k=s*h;K=b+S+b
r=s*t+s+l+n
while t:r+=s*t+f+S+f+s*(h-t)+b+n;t-=1
r+=l+k+b+n+(K+k+b+n)*(v-1)+K+k+p+n
while v:v-=1;r+=K+s*v+f+n
print r+l

```

Thanks to @marcog, for pointing out the first line, @ThomasO for pointing out the second line and to @Juan for making me realise I can combine lines.

# Answer
> 10 votes
Python - 179

```
h=input()*2
j=d=h/4
q,e,u,p,k="| \n+/"
w=e*d
s=p+'-'*h+p
i=''
o=e+w+s+u
v=q+e*h+q
while j:o+=e*j+k+e*h+k+e*(d-j)+q+u;j-=1;i+=v+e*j+k+u
print o+s+w+q+u+(v+w+q+u)*(d-1)+v+w+p+u+i+s

```

I'd like to note that I took some ideas from JPvdMerwe (Using a string to print once, and the one-liner for that I didn't know was correct syntax in Python).

# Answer
> 8 votes
## fortran 77 -- 484 characters

```
      program z
      read(*,*) i
      g=f('+- ',i/2+1,i,0)
      do k=1,i/2
         g=f('/ |',i/2-k+1,i,k-1)
      end do
      g=f('+-|',0,i,i/2)
      do k=1,i/2-1
         g=f('| |',0,i,i/2)
      end do
      g=f('| +',0,i,i/2)
      do k=1,i/2
         g=f('| /',0,i,i/2-k)
      end do
      g=f('+- ',0,i,0)
      stop
      end
      real function f(c,l,m,n)
      character c(3)
      write(*,*)(' ',j=1,l),c(1),(c(2),j=1,2*m),c(1),(' ',j=1,n),c(3)
      return
      end

```

No real point in providing a "unobsfucated" version. And note that markdown doesn't get along well with the indent requirements.

I tried fortran because of the inline for loops provided by the `write` statement. Obviously they help but don't add up to enough to kill the wordiess of the language. It could be reduce by using freeform input.

**Validation:**

```
 $ wc cube_func_array.f
 22  41 484 cube_func_array.f
 $ gfortran cube_func_array.f
 $ echo 2 | ./a.out
   +----+
  /    /|
 +----+ |
 |    | +
 |    |/
 +----+
 $ echo 4 | ./a.out
    +--------+
   /        /|
  /        / |
 +--------+  |
 |        |  |
 |        |  +
 |        | /
 |        |/
 +--------+

```

Thankfully the spec doesn't say what size one should look like:

```
 $ echo 1 | ./a.out
  +--+
 +--+|
 |  |+
 +--+

```

but other odd sizes are reasonable:

```
 $ echo 3 | ./a.out
   +------+
  /      /|
 +------+ |
 |      | +
 |      |/
 +------+

```

# Answer
> 5 votes
## PostScript, 237

```
[/n(%stdin)(r)file token()/p{print}/r{repeat}([){{( )p}r}/N{n 2 mul}(]){n 2 idiv}/l{N(+)p{(-)p}r(+)p}/I{(|)p}/X{][p}>>begin
( )X l()=]-1 1{dup[(/)p N[(/)p]exch sub[(|)=}for
l(|
)X]1 sub{I N[I(|
)X}r
I N[I(+
)X]-1 1{I N[I 1 sub[(/)=}for
l

```

History:

* 2011-03-01 01:54 **(427)** First attempt.
* 2011-03-01 02:01 **(342)** `def`ed a few more things that appeared often.
* 2011-03-01 02:24 **(283)** Even more `def`s.
* 2011-03-01 02:42 **(281)** Aaand another `def` that saves two more bytes.
* 2011-03-01 03:01 **(260)** `[` and `]` have nice properties when used as variables :-). Thanks to KirarinSnow.
* 2011-03-01 03:12 **(246)** Inline line breaks, using a dict instead of numerous `def`s. Thansk again :-).
* 2011-03-01 03:26 **(237)** More thanks to KirarinSnow.

# Answer
> 4 votes
My own solution, since it has already been beaten to death by Python:

### Windows PowerShell, 183

```
$t=($w=($s=' ')*($o=($n="$input")/2))*4
$r="|$t|"
$s*($a=$o+1)+($q='+'+'--'*$n+'+')
$o..1|%{$s*--$a+"/$t/$($s*$b++)|"}
"$q$w|"
for(;$o-++$x){"$r$w|"}"$r$w+"
--$b..0|%{$r+$s*$_+'/'}
$q

```

# Answer
> 3 votes
## Ruby 1.9, ~~172 165~~ 162 characters

```
w=(s=?\s)*o=(n=gets.to_i)/2;r=(z=?|)+w*4+z
puts s*(o+1)+q=?++?-*2*n+?+,(l=0...o).map{|u|[s*(o-u),w*4,s*u+z]*?/},q+w+z,[r+w+z]*o-=1,r+w+?+,l.map{|u|r+s*(o-u)+?/},q

```

# Answer
> 2 votes
## Ruby - 423 characters

Really don't want to share this since it's such a horrible count, but since I've written it might as well.

```
n=$<.read.to_i
a=(q=Array).new(n+n/2+3){q.new(2*n+n/2+3,' ')<<"\n"}
a[n+1][2*n+n/2+2]=a[0][n/2+1]=a[0][2*n+n/2+1]=a[n/2+1][0]=a[n/2+1][2*n]=a[n+n/2+2][0]=a[n+n/2+2][2*n]=:+
a[0][n/2+2,n*2-1]=a[n/2+1][1,n*2-1]=a[n+n/2+2][1,n*2-1]=[:-]*2*n
a[n/2+2,n].each{|b|b[0]=b[2*n+1]=:|}
a[1,n].each{|b|b[2*n+n/2+2]=:|}
c=n/2
a[1,n/2].each{|b|b[c]=b[2+2*n+c-=1]=:/}
c=n/2
a[n+2,n/2].each{|b|b[2+2*n+c-=1]=:/}
a.flatten.each{|g|print g}

```

Could probably be reduced by quite a bit but I doubt this brute-force approach is going to come anywhere near a decent number of characters so I can't be bothered.

# Answer
> 2 votes
# Vyxal `J`, 61 bytes

```
½:→›\+?-m:£꘍←ƛ\/?꘍m꘍;Ṙ?ɾv\|?꘍vm¥pJ←ʁ←›v←ȮṘJJ꘍?\|*\++←\/*+f+⁋¥

```

Try it Online!

This was harder than I thought it'd be. -4 thanks to @AaroneousMiller. Woo, beating ascii-art langs!

# Answer
> 1 votes
## PHP, ~~401~~ ~~392~~ ~~382~~ 363 characters:

```
<? $h=fgets(STDIN);$s="str_repeat";$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo$s($c,$h/2+1)."+".$s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo$s($c,($h/2+1)-$i)."/".$s($c,$w)."/".$s($c,$i-1)."|\n";}echo"+".$s("-",$w)."+".$s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".$s($c,$w)."|";echo $a-->0?$s($c,$b).($a>0?"|":"+")."\n":$s($c,$h-$i)."/\n";}echo"+".$s("-",$w)."+\n";

```

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

**Validation:**
http://codepad.viper-7.com/ftYYz9.php53
Ungolfed Version: http://codepad.viper-7.com/4D3kIA

# Answer
> 1 votes
## Perl, 163

```
$d=<>/2;$s=$"x$d;$H=$s x4;$f="|$H|";$t.=$"
x$d--."/$H/".$"x$_."|\n",$m.="$f$s|\n",$b
=$f.$"x$_."/\n$b"for 0..$d-1;$_="+$H+";
y/ /-/;say" $s$_\n$t$_$s|\n$m$f$s+\n$b$_"

```

Perl 5.10 or later, run with `perl -E '<code here>'`

Respaced version:

```
$d = <> / 2;
$s = $" x $d;
$H = $s x 4;
$f = "|$H|";

$t .= $" x $d-- . "/$H/" . $"x$_ . "|\n",
$m .= "$f$s|\n",
$b = $f . $" x $_ . "/\n$b"
  for 0 .. $d-1;

$_ = "+$H+";
y/ /-/;
say " $s$_\n$t$_$s|\n$m$f$s+\n$b$_"

```

# Answer
> 1 votes
### Perl, 269 269 262 256 245 244 237 226 228 224 217 chars

```
sub p{y/xS/+\//;print;y/+\//xS/}$b=/2;$a=$b;$_=" xx\n";s/ x/  x----/while($a--);until(/^S/){p;s/ [xS]/S /g;s/-x/S|/;y/-/ /}s/ (?= *S)/-/g;y/S/x/;p;y/-x/ |/;p while(--$b);s/.$/x/;while(/ \|/){p;s/..$/S/}y/|S /++-/;p

```

The basic idea is to do everything with regex substitutions. Because two of the characters used (+ and /) are special characters and turn up a lot in the regexes, it's worthwhile using other characters and substituting them to print.

Slightly more legible version:

```
# Subroutine to substitute, print, and unsubstitute as described above
sub p{y/xS/+\//;print;y/+\//xS/}
# Read from stdin and set up the initial line
$b=<>/2;$a=$b;$_=" xx\n";
s/ x/  x----/ while($a--);
# Print the top face
until(/^S/) {
  p;
  s/ [xS]/S /g; # First time round: left + -> /; subsequent times move / left
  s/-x/S|/; # Only relevant first time round the loop
  y/-/ / # Only relevant first time round the loop
}
# Prepare and print the line containing second horizontal line
s/ (?= *S)/-/g;
y/S/x/;
p;
# Now print (n-1)/2 identical lines
y/-x/ |/;
p while (--$b);
# Bring the right edge in
s/.$/x/;
while(/ \|/)
{
  p;
  s/..$/S/
}
# Final line
y/|S /++-/;
p

```

In a sense I'm cheating by using $b as a counter in the intermediate loop - I could instead append whitespace in the loop over $a and then use regex replaces for that loop too - but I'm going to allow that slight deviation from a pure-regex solution.

No doubt some scary person can turn this into a much shorter sed script.

# Answer
> 1 votes
# Lua, ~~294~~ ~~302~~ 292 bytes

Golfed:

```
n=(...)p="+"d=2*n s=" "S=s:rep(d)h=n/2 T=s:rep(h)L="\n"o="/"v="|"a=p..("-"):rep(d)..p r=T..s..a..L for i=0,h-1 do r=r..s:rep(h-i)..o..S..o..s:rep(i)..v..L end r=r..a..T..v for i=1,h do r=r..L..v..S..v..T..(i==h and p or v) end for i=h-1,0,-1 do r=r..L..v..S..v..s:rep(i)..o end print(r..L..a)

```

Ungolfed:

```
n        = n or io.read() or 6
plus     = "+"
doubled  = 2*n
space    = " "
Space    = space:rep(doubled)
halved   = n/2
T        = space:rep(halved)
Line     = "\n"
or_sign  = "/"
vertical = "|"
a        = plus..("-"):rep(doubled)..plus
result   = T..space..a..Line

for i=0,halved-1 do
    result = result .. space:rep(halved-i) .. or_sign .. Space .. or_sign .. space:rep(i) .. vertical .. Line
end

result = result..a..T..vertical

for i=1,halved do
    result = result .. Line .. vertical .. Space .. vertical .. T .. (i==halved and plus or vertical)
end

for i=halved-1,0,-1 do
    result = result .. Line .. vertical .. Space .. vertical .. space:rep(i) .. or_sign
end

print(result .. Line .. a)

```

# Answer
> 1 votes
# Canvas, 63 bytes

```
╴»
±╵⁷／╋╴«３＋⁷
-×+×║⌐１╴├╋；⁷├⁷±╋２⁷⁸⁸├⁷／╋１２╴«├２⁷５×３＋⁷±╵⁰２ｎ｛┤╴|＊+∔╋

```

Try it here!

# Answer
> 1 votes
# Vyxal, 40 bytes

```
½"‛|/f*?d¤-JǏz:Yf:@2+$¤p\+jǏ»×g=↔F»8τ„ø∧

```

Try it Online!

```
     f*                                  # Repeat each character of
  ‛|/                                    # "|/"
½"                                       # by each of [input, input/2]
          -                              # Append
       ?d                                # 2*input hyphens
         ¤                               # To the empty string
           J                             # Add that to the list
            Ǐz                           # Get all pairs
              :Yf                        # Double each pair
                                      ø∧ # Draw on canvas with
                 :@                      # Lengths: length of each of that
                   2+                    # + 2
                     $                   # String: That
                        \+j              # Joined by "+"
                      ¤p   Ǐ             # With a + at the start and end
                            »×g=↔F»      # Directions: compressed number
                                   8τ„   # Converted from base 8 to [4, 1, 0, 5, 1, 6, 5, 2, 6, 4, 2, 0]

```

---
Tags: code-golf, ascii-art
---


title: Chess960 position generator

text:
# Question
Title: Chess960 position generator
**Context**

> Chess960 (or Fischer Random Chess) is a variant of chess invented and advocated by former World Chess Champion Bobby Fischer, publicly announced on June 19, 1996 in Buenos Aires, Argentina. It employs the same board and pieces as standard chess; however, the starting position of the pieces on the players' home ranks is randomized

**Rules**

> * White pawns are placed on the second rank as in standard chess
> * All remaining white pieces are placed randomly on the first rank
> * The bishops must be placed on opposite-color squares
> * The king must be placed on a square between the rooks.
> * Black's pieces are placed equal-and-opposite to White's pieces.

From: http://en.wikipedia.org/wiki/Chess960

For all the people that would like to post answers...

you have to make a Chess960 positions generator, capable of randomly generate one of the 960 positions following the rules described above (it has to be capable of outputting any of the 960, hardcoding one position is not accepted!), and you only need to output the white rank one pieces.

Example output:

rkrbnnbq

where:

* k king
* q queen
* b bishop
* n knight
* r rook

This will be code golf, and the tie breaker will be the upvotes.

# Answer
> 6 votes
## GolfScript (49 48 chars, or 47 for upper-case output)

```
'bbnnrrkq'{{;9rand}$.'b'/1=,1$'r'/1='k'?)!|1&}do

```

This uses the standard technique of permuting randomly until we meet the criteria. Unlike w0lf's GolfScript solution, this does both checks on the string, so it is likely to run through the loop more times.

Using upper case allows saving one char:

```
'BBNNRRKQ'{{;9rand}$.'B'/1=,1$'R'/1=75?)!|1&}do

```

# Answer
> 8 votes
# Ruby 1.9, 67 65 characters

Ah, the old "keep randomizing until you generate something valid" technique...

```
$_=%w(r r n n b b q k).shuffle*''until/r.*k.*r/&&/b(..)*b/
$><<$_

```

(In Ruby 2.0, `%w(r r n n b b q k)` could be `'rrnnbbqk'.chars`)

# Answer
> 8 votes
## GolfScript ~~60~~ 49

```
;'qbbnnxxx'{{9rand*}$.'b'/1=,2%}do'x'/'rkr'1/]zip

```

(shortened to 49 chars thanks to Peter Taylor's great tips)

Online test here.

An explanation of the code:

```
;'qbbnnxxx'         # push the string 'qbbnnxxx' on the clean stack
{

    {9rand*}$       # shuffle the string

    .'b'/1=,2%      # count the number of places between the 'b's
                    # (including the 'b's themselves)
                    # if this count is even, the bishops are on
                    # squares of different colors, so place a 0
                    # on the stack to make the do loop stop

}do                 # repeat the procedure above until a
                    # good string is encountered

'x'/                # split the string where the 'x's are

'rkr'1/]zip         # and put 'r', 'k' and then 'r' again
                    # where the 'x's used to be

```

# Answer
> 5 votes
### J, 56 characters

```
{.(#~'(?=.*b(..)*b).*r.*k.*r.*'&rxeq"1)'kqbbnnrr'A.~?~!8

```

it takes several seconds on my machine due to the inefficient algorithm. Some speed may be gained by adding `~.`(remove duplicates) before `'kqbbnnrr'`.

explanation:

* `?~!8` deals `8!` random elements from `0 ... 8!`
* `'kqbbnnrr'A.~` uses them as anagram indexes to the string `kqbbnnrr`.
* `(#~'...'&rxeq"1)'` filters them by the regex in quotes.
* `{.` means "take the first element"

# Answer
> 4 votes
# K,69

```
(-8?)/[{~*(*/~~':{m=_m:x%2}@&x="b")&(&x="k")within&"r"=x};"rrbbnnkq"]

```

# Answer
> 3 votes
# Python, 105 chars

Basically chron's technique, minus the elegant Ruby stuff.

```
import re,random
a='rrbbnnkq'
while re.search('b.(..)*b|r[^k]*r',a):a=''.join(random.sample(a,8))
print a

```

Thanks to Peter Taylor for the shortening of the regex.

# Answer
> 1 votes
# Retina, ~~36~~ 30 bytes

*6 bytes saved thanks to Neil*

```

qbnbnrrr
/b.(..)*b/+V?`
1`r
k

```

Try it online!

### Explanation

```

qbnbnrrr

```

Start with the list of pieces except we have three rooks and no king

```
/b.(..)*b/+V?`

```

Keep shuffling the list as long as it matches the regex `b.(..)*b` (odd number of pieces between bishops)

```
1`r
k

```

Replace the second rook with a king

# Answer
> 0 votes
# Perl, 69 chars

```
$_=rrbbnnkq;/r[^k]*r|b.(..)*b/||say while s/(.{@{[time%8]}})(.)/$2$1/

```

To test it, add `$|=1;` at the beginning to see progress and keep tabs by pipeing into another perl process like this:

```
perl -E'$|=1;$_=rrbbnnkq;/r[^k]*r|b.(..)*b/||say while s/(.{@{[time%7]}})(.)/$2$1/' \
| perl -nlE'$a{$_}++ or say"$_ ".keys%a'

```

This will e v e n t u a l l y get the 960 valid permutations.

To run the test fast, swap out `time%8` with `int rand 8` like this:

```
perl -E'$_=rrbbnnkq;/r[^k]*r|b.(..)*b/||say while s/(.{@{[int rand 8]}})(.)/$2$1/' \
| perl -nlE'$a{$_}++||say"$_ ".keys%a'

```

---
Tags: code-golf, combinatorics, chess
---