Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Looping counter

+8
−0

Looping counter

Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. However all lines need to use the same character.

The beginning of the output looks like this:

*
**
***
****
*****
******
*******
********
*********
**********
***********
************

An ungolfed Python implementation:

from itertools import count

for i in count(1):
    print('*'*i)
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

18 answers

+5
−0

Lua, 31 bytes

_=''::_::_=_..'*'print(_)goto _

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

You can shorten your loop by using goto. As a bonus, this makes your code look even more cryptic (: ... (2 comments)
+3
−0

Vyxal, 5 4 bytes

¤{‹…

Try it Online!

This is so stupid and I love it

Explained

¤{‹…
¤     # Push an empty string
 {    # Forever:
  ‹   #   Append a "-" to the top of the stack
   …  #   And print it without popping
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+3
−0

Ruby, 18 bytes

loop{$><<$/=?*+$/}

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−0

MATL, 16 bytes

1`1yh1$lZctDwQt]

Try it online!

The TIO output fetch will likely fail, so make sure to click the run button to stop the execution.

1`1yh1$lZctDwQt]
1`             ] - Push 1 onto stack, enter do-while
  1              - Push 1 onto stack
   y             - duplicate n-th level of stack, default is 2
    h            - horzcat, 1 10h -> [1;10]
     1$l         - ones, specifying arguments with 1$
        Zc       - strjoin
          t      - duplicate top of stack
           D     - display
            w    - swap
             Q   - increment by 1
              t  - duplicate

Matlab can loop infinitely using k=1:inf, but MATL cannot perform [1:Y] where Y is shorthand for inf.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−0

Haskell, 35 bytes

main=mapM putStrLn$iterate('*':)"*"

Attempt This Online!

55 -> 39, with orthoplex's idea.

39 -> 35 from orthoplex.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Neat solution, but that import is quite expensive. Maybe try something like ```haskell x="*":map('*... (3 comments)
+1
−0

brainfuck, 31 bytes

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

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

dc, 13 bytes

[r1+pA*rdx]dx

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 28 bytes

_=""
while 1:_+="*";print(_)

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Bash, 17 bytes

echo x$1;./$0 x$1

Try it online!

Thanks to celtschk‭ for spotting my mistake :)

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Wrong output (1 comment)
+1
−0

JavaScript (Node.js), 31 bytes

for(i='';;console.log(i+='*'));

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Embed ESCR, about 32 characters depending on how you count

loop
  append s "*"
  show s
  endloop

The indentation is not required, but shown for clarity. Declaring the variable S is also not included, since similar stuff doesn't seem to be included in other examples.

S is a string variable. In ESCR, storage for a string can grow dynamically at run time as needed. The string initialially starts empty, with one "*" appended to it each iteration.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript, 25 bytes

Could be 21 but calling the function like that feels like cheating.

(f=s=>f(s+=8,print(s)))``

Try it online!

22 bytes

Didn't want to post this as my main solution as it's pretty much the same as Moshi's.

for(s=``;;)print(s+=8)

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

C (gcc), 47 bytes

i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();}

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

J, 13 char

'*',^:(<_)'*'

How it works: What's in parenthesis indicates to the verb ^: that the verb to the left of ^: has to be performed to the object on the right of the ^: an infinite number of times and that it has to list each intermediate result. '_' is infinity, and '<' boxes it to force listing the intermediate results.

   '*',^:(<4)'*'
*   
**  
*** 
****
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

><>, 10 bytes

1:naoa*1+!

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt, 6 bytes

ßOpP±Q

Test it

ßOpP±Q
ß          :Recursive call
 Op        :Output with trailing newline
   P       :Empty string, initially
    ±      :Append
     Q     :Quotation mark
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 2, 26 bytes

_=1
while 1:_*=10;print~-_

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Fig, 5 bytes

The actual score is $5\log_{256}(96)\approx$ 4.116 bytes. The leaderboard only likes ints in the header.

(J,Q0

-1 char thanks to Seggan

Try it online!

Fractional byte lang created by Seggan. Is this even allowed here?

(J,Q0
  ,Q    : Print and return last return value, initialized as 0
 J  0   : Add 0 to end of result
(       : Loop forever
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

The leaderboard thinks this is 116 bytes lol. You might want to change it to 4 or 5 (2 comments)

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate