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 communityWrite 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.
fun main(a:Array<String>){while(0<1)print("A")}
1.) Thanks to @Adam for pointing out the args naming
while(0<1)print("A")
\$\endgroup\$
1 byte off thanks to @Yelp!
while printf('A')end
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.
printf
\$\endgroup\$
Jun 28, 2021 at 22:10
$<65.C=-1.
With whitespace and comments:
$< 65. ; Print 65 as unicode 'A'
C = -1. ; Set program counter to -1 (advances to 0 afterwards)
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.
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.
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.
;#58#46#35#63#!#65#?
;#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
g,_@
1A
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
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.
This version's memory usage grows without bound.
"Ao
[65Pdx]dx
[ ] # 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
#import<iostream>
int A(){for(;;)std::cout<<'A';}
Uses C++ I/O.
#import<ios>
int A(){for(;;)printf("A");}
Uses C I/O.
#include<cstdio>
and your cout
with printf
loses 4 bytes. I tried to paste my revision, but found myself incapable on mobile…
\$\endgroup\$
int A(){for(;;)__builtin_printf("A");}
is shorter; you can remove the import
\$\endgroup\$
Mar 6, 2020 at 3:43
You need an extra newline to enter the instruction. It's a modification of this solution.
/-A
The trailing newline is significant.
/ 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É'Aq↑
Or
æ'A_q▲
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
yes A|tr -d \\n
\$\endgroup\$
{print;redo}
A
character under the flags!
\$\endgroup\$
perl -l101 -E '{print;redo}'
The command line parameters are important.
\$\endgroup\$
Mar 4, 2020 at 1:53
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
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
while(1)
with for(;;)
and -1 byte
\$\endgroup\$