Write a script that outputs A
to stdout infinitely.
There should be no newlines or separators between the characters.
Standard loopholes apply.
This is code-golf. The shortest solution in each language wins.
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this community'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.
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
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.
ͻ # Infinite loop
( # Decompress base 255
A # A
) #
B # Compress number to base 255
avqviiimtfu
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
class P{static void Main(){for(;;)System.Console.Write('A');}}
{iiiiii}iiiii{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{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}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
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.
Do
WScript.StdOut.Write("A")
Loop
for(;;)Console.Write('A');
.
\$\endgroup\$
System
is added as a using
directive with every class file generated. So creating a new console app to test this will include the System
namespace by default. Plus, you can add a web link for testing with DotNETFiddle which also includes System
by default with new fiddles.
\$\endgroup\$
System
using is not added by default.
\$\endgroup\$
Aug 19, 2021 at 19:28
^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.
while 1>0:stdout.write'A'
Not great, but not too shabby.
stdout.write
.
\$\endgroup\$
65|[,]0
If you run this on the online interpreter, you'll get an error message saying the code timed out with no output. That's only due to how this online interpreter is set up* - if you run this locally, it will never stop printing AAAAAAAAAAAAAAAAAAAAAAAA...
. Online CPU-seconds are expensive!
*it's supposed to still give output even if an error gets thrown because it is an interpreted language, but I don't know how to set that up properly on the website. So as of right now, output in the online version only gets printed if the program exits successfully...
Rattle prints the top of the stack implicitly upon exit. However, this code will never exit. If you run this on the online interpreter with a finite loop (change the 0
to 100
or something), you'll notice that 65
gets printed at the end. Of course, the end of infinity doesn't exist, so this code is still valid.
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)
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.
'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
for(;;)
instead of while(1)
to save 1 byte : )
\$\endgroup\$
{Oo'A}g1/0
{Oo'A}a
{ // Function
Oo'A // Output 'A'
} // End Function
g1/0 // Call infinite times
// (Japt's O.o() method returns undefined)
As pointed out by @Shaggy due to how a
is implemented this will print A
only 1e8
times
{Oo'A}a
{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)
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.
The try it link has the 5
flag to prevent it from freezing up forever.
{\A₴
{ - While loop
\A - Push "A"
₴ - Print without newline
DO,1<-#9DO,1SUB#1<-#126DOCOMEFROM#9PLEASEREADOUT,1(9)DO,1<-#9
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.
'A?
'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.
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
o
(for output), instead of s_{tdout}
. Also, \to
can be replaced with ->
. Taking these golfs into consideration, the code would be 18 bytes
\$\endgroup\$
Apr 26 at 7:03
'A'~{dup~ow~}~loop~
Pretty much a duplicate of my "Shortest code to produce infinite output" answer.
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> ..
sed
. I had to use the-z
flag just to even remove one. \$\endgroup\$