title: Draw an asterisk triangle

text:
# Question
Title: Draw an asterisk triangle
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

## Input:

* A positive integer `n >= 1`.

## Output:

* `n` lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

## Test case (n=5):

```
    *
    **
    ***
    ****
    *****

```

This is , so shortest answer in bytes wins.

# Answer
# Vim, 8 bytes

```
o <Esc><C-V>{r*J

```

Takes input in the readahead buffer, so if input is 15, you would type that and then the code above. This is a silly rule, but *seems* to be allowed. If you got input in a register like `"a`, you'd just stick `@a` in front (10). If you got it from the start file, you'd prepend `D@"` instead (11).

Relies on abuse of `:set autoindent`, which is default in vimgolf.com rules and default in Vim 8 (and everyone uses it anyway).

* `o <Esc>`: With its number argument, if your text starts with whitespace, and you have `:set autoindent`, Vim glitches out and creates a cascade of indent.
* `<C-V>{r*`: Turn all those spaces into `*`s. I'm using block visual so that, even if your lousy indent settings silently group your spaces into tabs, you'll still get the right number of `*`s.
* `J`: Starting with `o` unfortunately left a blank line at the top. This removes it.
> 44 votes

# Answer
# JavaScript (ES6), 31 bytes

This one includes both a leading and a trailing line-break.

We start with a string `s` containing only a line-break. Then we process `n` recursive calls, adding an asterisk on the left side of this string at each iteration. The concatenation of all intermediate strings leads to the expected result.

```
f=(n,s=`
`)=>n?s+f(n-1,'*'+s):s

```

Try it online!

### Without asterisk, 36 bytes

```
f=(n,s=`
`)=>n?s+f(n-1,atob`Kg`+s):s

```

Try it online!
> 24 votes

# Answer
# 05AB1E, ~~7~~ 6 bytes

Uses CP-1252 encoding.

```
'*×.p»

```

**8 byte no-asterisk version:**

```
žQTè×.p»

```

Try it online!

**Explanation**

Example using input `n = 5`

```
'*      # push "*"
        # STACK: "*"
  ×     # repeat input number times
        # STACK: "*****"
   .p   # get prefixes of string
        # STACK: ['*', '**', '***', '****', '*****']
     »  # join by newlines
        # implicit print

```
> 19 votes

# Answer
# PowerShell, ~~21~~ 20 bytes

```
1.."$args"|%{'*'*$_}

```

Try it online!

Loops from `1` to input `$args`, each iteration using string multiplication to construct a string of that many `$_` asterisks. Default behavior for the implicit `Write-Output` at the end is with a newline for separator, so we get that for free.

```
PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5
*
**
***
****
*****

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2
*
**

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7
*
**
***
****
*****
******
*******

```

*-1 byte thanks to Veskah.*
> 15 votes

# Answer
# Jelly, ~~6~~ 5 bytes

```
”*ẋþY

```

**TryItOnline**

### How?

```
”*ẋþY - Main link: n
”*    - literal string "*"
   þ  - form outer product with the dyadic function:
  ẋ   -     repeat list (right input is an implicit range(n), Jelly defaults to 1-based)
            so the outer product is like:
            [[i*'*' for i in range(1,len("*")+1)] for x in range(1,n+1)]
    Y - join with line feeds
      - implicit print

```

---

Bounty:
I'm not sure what the no ordinals clause is, since a character *is* a lookup of an ordinal.
Direct lookup would just be `42Ọẋþ³Y` for **7 bytes** \- where the `³` gets us the input)
A short slightly indirect method would be, for **8 bytes**, `“)’Ọẋþ³Y` \- where we lookup `')'` in jelly's code page, which is 1-indexed so `“)’` yields 42.
> 13 votes

# Answer
# Python 2, ~~37~~ 34 bytes

```
i=1;exec"print'*'*i;i+=1;"*input()

```

**Ideone**

`i` is initialised to `1`;
then `exec` commands to execute the following string of code, so it must be constructed;
the string is `"print'*'*i;i+=1;"` but the `*` following the string takes precedence over the `exec` and instructs to first repeat the string `input()` times;
the `exec` command now executes the long string which acts like a loop, `print`ing another string of increasing length, again using `*` to repeat the character `'*'`, then incrementing `i` with `i+=1`.

**Python 3, 41 bytes:**
`def f(n):i=1;exec("print('*'*i);i+=1;"*n)`; or
`lambda n,i=1:exec("print('*'*i);i+=1;"*n)`
> 13 votes

# Answer
# C#, 42 bytes

```
f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);

```

Full program with test case:

```
using System;

namespace DrawAnAsteriskPattern
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,string>f= null;
            f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);

            Console.WriteLine(f(5));
        }
    }
}

```
> 11 votes

# Answer
# GNU sed, ~~25~~ ~~24~~ 20 + 1(n flag) = 21 bytes

*Edit:* 4 bytes less based on Riley's comments

```
x;G;:;P;s:\n.:*\n:;t

```

**Try it online!**

**Run example:** the input is in unary format, which for sed is allowed based on this consensus

```
me@LCARS:/PPCG$ sed -nf draw_triangle.sed <<< "0000"

*
**
***
****

```

A leading newline is present in the output, but this is allowed by the OP.

**Explanation:**

```
x;G             # prepend a newline to unary string
:               # start loop
   P            # print first line only
   s:\n.:*\n:   # shift one unary char from 2nd line to 1st, converted to a '*'
t               # repeat

```
> 10 votes

# Answer
# Pyth, 6 bytes

```
j._*"*

```

**Try it here**.

### Explanation

```
j            Join by newlines
 ._          all prefixes of
    *        the result of repeating
      "*     the string "*"
             as many times as the implicit input

```
> 10 votes

# Answer
# Matlab, 26 23 bytes

Good old Matlab...

```
@(n)tril(repmat('*',n))

```

Has trailing whitespaces. `tril` gives you the lower triangular matrix.

edit: saved 2 bythes thanks to Luis Mendo
> 8 votes

# Answer
# C++ - 92 96 Bytes

```
#include<string>
int main(){int n;std::string s;scanf("%d",&n);for(;n--;)puts((s+="*").data());}

```

Try it online

Ungolfed:

```
//this one hurts, but c++ strings are mutable
#include<string>
int main(){
    int n;
    //this one hurts as well
    std::string s;
    //read input to n
    //longer than 'std::cin>>n', but no #include<iostream> needed
    scanf("%d",&n);
    // same as 'while(n--)', also characterwise, but way cooler
    for(;n--;)
        //add a '*' the string
        //data() does the same as c_str()
        //puts automatically adds an '\n'
        puts((s+="*").data());
}

```
> 8 votes

# Answer
## Jellyfish, ~~12~~ ~~11~~ 9 bytes

```
\P$'*
  i

```

Try it online!

### Explanation

The above program is equivalent to the following functional pseudocode:

```
\            P      $       i        '*
map_prefixes(print, reshape(input(), '*'))

```

The `$` (reshape) creates a string of `N` asterisks. `\P` creates a function which takes a list (or string) and passes each of its prefixes to `P` (print). Hence, this successively prints strings of `1` to `N` asterisks.
> 7 votes

# Answer
# Haskell, 35 ~~38~~ bytes

List comprehension thanks to nimi:

```
f x=unlines[[1..n]>>"*"|n<-[1..x]]

```

Old version:

```
f 0=""
f n=f(n-1)++([1..n]>>"*")++"\n"

```

Alternate version:

```
g n=([1..n]>>"*")++"\n"
f n=[1..n]>>=g

```
> 7 votes

# Answer
## R, 45 bytes

For loop approach:

```
for(i in 1:scan())cat(rep("*",i),"\n",sep="")

```
> 7 votes

# Answer
# Brachylog, 12 bytes

```
yke:"*"rj@w\

```

Try it online!

This assumes that a trailing new line is acceptable

### Explanation

```
yk                The range [0, …, Input - 1]
  e               Take one element I of that range
   :"*"rj         Juxtapose "*" I times to itself
         @w       Write that string followed by a new line
           \      False: backtrack to another element of the range

```

### No trailing new line, 15 bytes

```
-:"*"rj:@[f~@nw

```

Try it online!

This one works by taking all prefixes of `"*" × Input`.
> 6 votes

# Answer
# Pyth, 7 Bytes

```
VQ*\*hN

```

Knocked off a byte thanks to **@ETHproductions** Try it online

# **using @PIetu1998's Technique**

**6, bytes**

```
j*L*\*S

```
> 6 votes

# Answer
# Brain-Flak 75 Bytes

Includes +3 for `-A`

```
{(({})[()]<{({}[()]<(((((()()()){}()){})){}{})>)}{}((()()()()()){})>)}{}

```

Try it online!

---

**Explanation:**

```
{(({})[()]<                                                        >)}
#reduce the top element by one until it is 0 after doing the following
#Push this element back on to act as a counter for the next step.
#(counts down from input to 0 we'll call this counter)

           {({}[()]<                          >)}
           #reduce the top element by one until it is 0 after doing the following
           #(counts down from counter to 0)

                    (((((()()()){}()){})){}{})
                    #push 42 (the ASCII code for *)

                                                 {}
                                                 #pop the counter used to push
                                                 #the right number of *s

                                                   ((()()()()()){})
                                                   #push a 10 (newline)

                                                                      {}
                                                                      #pop the null byte

```
> 6 votes

# Answer
# 2sable, ~~24~~ 11 bytes

```
>G')Ç>çJN×,

```

Try it online!

And no sign of any asterisks! Golfed from 24 to 11 thanks to @Emigna.

Explanation:

```
>G')Ç>çJN×,
>            Push input+1
 G           For N in range (1,input+1)
  ')Ç>çJ     Push '*' by getting ascii code for ')' and adding 1
        Nx,  Print '*' repeated N times

```
> 6 votes

# Answer
# Dyalog APL, 8 bytes

```
↑'*'⍴⍨¨⍳

```

matrify the list consisting of

`'*'` the string "\*"

`⍴⍨` reshaped by

`¨` each of

the integers 1 through the argument.

TryAPL online!
> 6 votes

# Answer
# , 8 bytes

```
Àé*hòlÄx

```

Try it online!
> 5 votes

# Answer
# JavaScript (ES6), 34 bytes

```
f=x=>x?f(x-1)+`
`+'*'.repeat(x):''

```
> 5 votes

# Answer
# Perl 5, 22 20 bytes

```
say"*"x$_ for 1..pop

```

Run it with the `-E` switch to get `say`.

```
$ perl -E 'say"*"x$_ for 1..pop' 5
*
**
***
****
*****

```

Written out as a full program it would look like this:

```
use strict;
use feature 'say';

# get the argument
my $limit = pop @ARGV;

foreach my $i (1 .. $limit) {
    say "*" x $i;
}

```
* `shift` and `pop` implicitly work on `@ARGV` (the list of arguments) outside of subs
* `..` is the range operator
* `say` includes a newline
* `x` is an operator to repeat strings and is explained in perlop
> 5 votes

# Answer
# Perl 6, 23 bytes

```
{.put for [\~] '*'xx$_}

```

( If the output is allowed to be a list of "lines" without newlines `.put for` can be removed )

## Explanation:

```
# bare block lambda with implicit parameter ｢$_｣
{
  .put            # print with trailing newline
    for           # for every one of the following
      [\~]        # produce using concatenation operator
        '*' xx $_ # list repeat '*' by the input
}

```

( See documentation for `produce` if you don't understand what `[\~] ...` is doing )
> 5 votes

# Answer
## Perl, 19 bytes

*-4 bytes thanks to @Ton Hospel and his rework of the solution!*

```
eval"s//*/;say;"x<>

```

Needs free `-E` (or `-M5.010`) flag to run. Takes a number from input :

```
perl -E 'eval"s//*/;say;"x<>' <<< "5"

```
> 5 votes

# Answer
# J, ~~11~~ 8 bytes

*Saved 3 bytes thanks to miles!*

```
]\@#&'*'

```

Here is a decomposition:

```
(]\@#&'*') x
x (]\@#) '*'
]\ (x # '*')

```

Now, this last one reads as "the prefixes (`]\`) of the string consisting of `x` copies of `'*'`". Observe:

```
   5 ]\@# '*'
*
**
***
****
*****
   ]\ 5# '*'
*
**
***
****
*****
   ]\ 5 # '*'
*
**
***
****
*****
   ]\@#&'*' 5
*
**
***
****
*****

```

## Test case

```
   f =: ]\@#&'*'
   f 3
*
**
***
   f 5
*
**
***
****
*****
   f 1
*
   f 2
*
**
   f &. > ;/1+i.10
+-+--+---+----+-----+------+-------+--------+---------+----------+
|*|* |*  |*   |*    |*     |*      |*       |*        |*         |
| |**|** |**  |**   |**    |**     |**      |**       |**        |
| |  |***|*** |***  |***   |***    |***     |***      |***       |
| |  |   |****|**** |****  |****   |****    |****     |****      |
| |  |   |    |*****|***** |*****  |*****   |*****    |*****     |
| |  |   |    |     |******|****** |******  |******   |******    |
| |  |   |    |     |      |*******|******* |*******  |*******   |
| |  |   |    |     |      |       |********|******** |********  |
| |  |   |    |     |      |       |        |*********|********* |
| |  |   |    |     |      |       |        |         |**********|
+-+--+---+----+-----+------+-------+--------+---------+----------+

```

## Older, 11-byte solutions

```
'*'#~"+1+i.

```

This is equivalent

```
'*' #~"0 1 + i.

```

`1 + i.` is the range `[1, x]`. Then, `'*' #~"0` applied to this range shapes (element) copies of `'*'`.

Bonus program:

```
[:#&'*'\#&1

```

This is a capped fork `#&'*'\` applied to the result of `#&1` of the input. `#&1` gives an array of `x` ones, and `#&'*'\` shapes `'*'` to the prefixes of this array.

### Test cases

```
   f1 =: '*'#~"+1+i.
   f2 =: [:#&'*'\#&1
   f1 1
*
   f2 2
*
**
   f1 3
*
**
***
   f2 4
*
**
***
****
   f2 5
*
**
***
****
*****
   f1 5
*
**
***
****
*****
   (f1;f2)3
+---+---+
|*  |*  |
|** |** |
|***|***|
+---+---+
   f1;f2
f1 ; f2
   (f1;f2)5
+-----+-----+
|*    |*    |
|**   |**   |
|***  |***  |
|**** |**** |
|*****|*****|
+-----+-----+
   (f1;f2)10
+----------+----------+
|*         |*         |
|**        |**        |
|***       |***       |
|****      |****      |
|*****     |*****     |
|******    |******    |
|*******   |*******   |
|********  |********  |
|********* |********* |
|**********|**********|
+----------+----------+

```
> 5 votes

# Answer
# C, ~~47~~ ~~46~~ ~~45~~ 43 bytes

Takes input from the command line

```
f(n){for(n&&f(n-1);~n;putchar(n--?42:10));}

```

Basically if n is not 0 recurse on n-1. at the top of the recursion where n is 0 it just prints a newline, the for loop terminates when n is -1 or ~n is zero, otherwise it prints ASCII 42 which is '\*'. Try it on ideone

# C++ 58 Bytes + 19 for including iostream is 77

```
#include<iostream>
int f(int n){for(n&&f(n-1);~n;std::cout<<(n--?"*":"\n"));}

```

```
main(c,v)char**v;
{
    f(atoi(v[1]));
}

```

```
a.exe 3
*
**
***

```
> 5 votes

# Answer
# Vim, ~~22~~, 18 keystrokes

```
O <esc>J:h r<cr>lyEZZ<C-v>{@"

```

Huge credit to @Udioica for coming up with an awesome vim answer that I expanded on. This answer does not contain any asterisks, in hopes of winning the bounty.

Explanation:

Input is typed before the rest of the program. Udioica came up with this awesome trick. Typing `<n>O <esc>` will create a pyramid of spaces and one empty line, as long as you have `:set autoindent` enabled. This option comes on by default in vim 8 and neovim, though not older versions of vim. Since this also creates an extra line, we use `J` to join this line with the next one, which effectively just removes the line below us.

Now at this point, we need to replace all of these spaces with asterisks. If I was not worried about using asterisks in my code, I would just visually select the whole thing `<C-v>{` and type `r*`, which replaces each character of the selection with an asterisk. But I can't do that.

So we open up the help pages to `:h r`. The interesting thing about this is that in the vim-window, this page is displayed as:

```
                            r
r{char}         Replace the character under the cursor with {char}.
                ...

```

With the cursor on the first 'r'. However, the file itself actually contains this text:

```
                            *r*
r{char}         Replace the character under the cursor with {char}.
                ...

```

Pretty convenient. So we move over one character with `l`, and yank the text `r*` with `yE` (\[y\]ank to the \[E\]nd of this word).

To close this buffer, we use the shortcut to save a file `ZZ`. Now, we visually select our spaces, and run the yanked text as if we had typed it by doing `@"`. This works because "@" runs the following register as vim-keystrokes, and " is the default register for yanking.
> 5 votes

# Answer
# Commodore 64/VIC-20 BASIC (and compatible C= 8-bits), ~77 tokenized BASIC bytes

```
0 INPUT"NUMBER OF *";A:ON-(A<1)GOTO1:J=1:FORI=1TOA:FORX=1TOJ:PRINT"*";:NEXTX:J=J+1:PRINT:NEXTI
1 :

```

Technically line 1 isn't required, but I'm mis-using the `ON...GOTO` command as a conditional `GOTO` in line zero so I added in the shortest possible line 1 to end it gracefully.

You will need to use Commodore keyword abbreviations to fit line zero on a C64, see the screen shot below (Note that the C128 in 128 mode might have different keyword abbreviations, but then you can enter more characters so you probably won't need it):
> 5 votes

# Answer
## Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

```
.+
$**
.
$`$&¶

```

Try it online!

### Explanation

```
.+
$**

```

Turn the input `N` into `N` asterisks.

```
.
$`$&¶

```

Replace each asterisk with everything up to and including that asterisk (this is the `$`$&`) and a linefeed (this the ).
> 4 votes

# Answer
# Java ~~7~~ 11, ~~88~~ ~~73~~ 58 bytes

```
String c(int n){return(n<2?"":c(n-1)+"\n")+"*".repeat(n);}

```

-15 bytes by converting to Java 11.

Try it online. (NOTE: `String#repeat(int)` is emulated as `repeat(String,int)` for the same byte-count, because TIO doesn't contain Java 11 yet.)

**Explanation:**

```
String c(int n){          // Recursive method with integer parameter and String return-type
  return(n<2?             //  If `n` is 1:
          ""              //   Start with an empty String
         :                //  Else:
          c(n-1)          //   Start with a recursive call with `n-1`
                +"\n")    //   and a trailing new-line
         +"*".repeat(n);} //  And append `n` amount of '*'

```
> 4 votes

# Answer
# MATL, ~~9~~ 8 bytes

*1 byte saved thanks to @Luis*

```
:"42@Y"c

```

**Try it Online**
> 4 votes

# Answer
# CJam, ~~13~~ ~~11~~ 10 bytes

*Thanks to @MartinEnder for removing two bytes, and @Linus for removing one more!*

```
ri{)'**N}%

```

Try it online!

### Explanation

```
ri            e# Read input as an integer n
  {     }%    e# Run this block for each k in [0 1 ... n-1]
   )          e# Add 1 to the implicitly pushed k
    '*        e# Push asterisk character
      *       e# Repeat the character k+1 times
       N      e# Push newline
              e# Implicitly display

```
> 4 votes

# Answer
# Cubix, 22 bytes

```
?(.;I:^;/-.@o;(!\>'*oN

```

**Test it online!** Outputs a trailing newline.

At first I wasn't sure I could get this to fit on a 2-cube, but in the end it worked out fine:

```
    ? (
    . ;
I : ^ ; / - . @
o ; ( ! \ > ' *
    o N
    . .

```

I'll add an explanation when I have time, hopefully later today.
> 4 votes

# Answer
# Pushy, 4 bytes

```
:42"

```

**Try it online!**

This method takes advantages of Pushy's automatic int/char conversion:

```
        \ Implicit: Input on stack
:       \ Input times do: (this consumes input)
 42     \   Push 42 (char '*')
   "    \   Print whole stack

```

Because each iteration adds a new `*` char, this outputs a triangle. For example, with `n=4`:

```
*       \   Stack: [42]
**      \   Stack: [42, 42]
***     \   Stack: [42, 42, 42]
****    \   Stack: [42, 42, 42, 42]

```
> 4 votes

# Answer
# LaTeX, 171 bytes

I had to use LaTeX instead of plain TeX for the `\typein` macro...

Here it is, as golfed as I could:

```
\documentclass{book}\begin{document}\typein[\n]{}\newcount\i\newcount\a\i=0\loop{\a=0\loop*\advance\a by1\ifnum\i>\a\repeat}

\advance\i by1
\ifnum\n>\i\repeat\enddocument

```

Explanation:

```
\documentclass{book}% Book because it is shorter than article ;)
\begin{document}% Mandatory...
\typein[\n]{}% User inputs \n
\newcount\i% Create a line counter
\newcount\a% And an asterisk counter
\i=0% Initializes the line number to zero
\loop{% Line number loop
   \a=0% Sets the number of asterisks to zero
   \loop% Asterisk loop
   *% Prints the asterisk
   \advance \a by 1% Adds one to \a
   \ifnum\i>\a% If the line number is smaller than the number of asterisks
   \repeat% Then repeat
     }% Otherwise prints a new line

\advance\i by 1% And add 1 to the line counter
\ifnum\n>\i% If input number is less than the number of lines then
\repeat% Repeat
\enddocument% And finish LaTeX

```
> 4 votes

# Answer
# , 33 bytes

```
cat(strrep("*",1:scan()),sep="
")

```

Try it online!

I hope it's not a dupe - I was able to find only one other R answer. Leverages `strrep` and vectorization to build the vector `"*","**",...,"******"` and prints with `cat` using `newline` as a separator.
> 4 votes

# Answer
# Dyalog APL, 8 bytes

```
'*'/⍤0⍨⍳

```

Explanation:

1. `'*'`: Literal character `*`.
2. `/⍤0⍨`: Select each 0-ranked vector (scalar) according to.

* `/`: Select from the right argument according to the left.
* `⍤0`: Apply the preceding function to each scalar in the left and right arguments.
* : Apply the preceding function, but with the left and right arguments switched (so we select now from the left argument according to the right).

3. : Generate integers from 1 to the argument (inclusive)
> 4 votes

# Answer
# 05AB1E, ~~7~~ 5 bytes

```
L'*×»

```

Try it online!
> 4 votes

# Answer
# Rockstar, 47 bytes

```
listen to N
X's0
while N-X
let X be+1
say "*"*X

```

Try it here (Code will need to be pasted in)
> 4 votes

# Answer
# Regenerate, 3 bytes

```
\*+

```

You need to pass the input using `-l` flag.

Example run:

```
wasif@wasif:~/Downloads/Regenerate$ python3 regenerate.py -l 5 '\*+'
*
**
***
****
*****
wasif@wasif:~/Downloads/Regenerate$

```
> 4 votes

# Answer
## Batch, 69 bytes

```
@set s=
@for /l %%i in (1,1,%1)do @call set s=*%%s%%&call echo %%s%%

```
> 3 votes

# Answer
# Ruby, 26 bytes

```
->n{s='';n.times{p s+=?*}}

```
> 3 votes

# Answer
# Brainfuck, 70 bytes

```
,>++++++[<-------->>>+++++++<<-]<[>+[->+>.<<]>[-<+>]++++++++++.[-]<<-]

```

I'm sure this could be golfed a little bit. This version only works for single-digit numbers; feel free to modify it to work on larger numbers too.

Edit: If it's allowed to use a single character's ASCII value as the input, the resulting code is below. Only 60 bytes.

```
,>++++++[>>+++++++<<-]>[>+[->+>.<<]>[-<+>]++++++++++.[-]<<-]

```

Explanation:

```
,>++++++[<-------->>>+++++++<<-]  [this gets a single character from
input into the first cell, subtracts 48 to convert it to an integer
representation, and puts 42 in the 3rd cell (ASCII '*').]

<[ while the first cell is not zero do
    >+   add 1 to 2nd cell (empty when we start)
    [->+>.<<]  [while 2nd cell is not empty subtract 1 and print an *.
                Make a copy in 3rd cell.]
    >[-<+>]  copy 3rd cell value back to 2nd cell
    ++++++++++.[-] [put '\n' in 3rd cell, print, clear]
    <<-
 ] loop

```

Edit: Here is a version that works for numbers up to 255, reading the *text* representation of the number followed by EOF. If your favorite interpreter has unbounded cells it will work up to 999.

```
>>,[----------
[
    >++++++[<------>-]<--
>],]

[
 Pointer is one past the end of a run of digits containing input.
 Assumption: input < 256.
 Add ten times most significant digit to second and ten times the
 second to the third to get it in one cell.
]

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

Store 42 '*' in the cell 3 to the right
>>++++++[>+++++++<-]<<

[ While first cell is not empty
    >+ Add 1 to 2nd cell
    [->+>.<<] [make a copy in 3rd cell, print '*']
    >[<+>-] copy 3rd back to 2nd
    ++++++++++.[-] print newline and clear 3rd
    <<- subtract 1 from 1st and continue
]

```
> 3 votes

# Answer
## Actually, 8 bytes

```
R`'**`Mi

```

Try it online!

Explanation:

```
R`'**`Mi
R         range(1, n+1) ([1, 2, ..., n])
 `'**`M   for each element: that many asterisks
       i  flatten and implicitly print

```

---

## 5 bytes

```
R'**i

```

Try it online!
> 3 votes

# Answer
# RProgN, 41 Bytes.

24 of these bytes are just assigning R and s, so that we can use a spaceless segment.

```
'rep' º 'R' = '*' 's' = ►]¿]s\R\1-]}[

```

## Explination

```
'rep' º 'R' =       # Get the function for 'rep' (Replace), associate 'R' with it.
'*' 's' =           # Associate 's' with the string literal '*'
►                   # Begin spaceless segment.
    ]               # Push a copy of the top of the stack (The input)
    ¿               # While truthy, popping the top of the stack.
        ]           # Push a copy...
        s \ R       # Push an *, swap the two top values giving "i, *, i", Repeat the *, i times, giving "i, ****", or whatever.
        \ 1 -       # Swap the top values, giving "****, i", decrement the top value by 1.
        ]           # Push a copy of the top value.
    }[              # End the while, after processing, pop the top value (Which would be 0). Implcititly print.

```

## Try it!

```
<style>
  #frame{
    width:60em;
    height:60em;
    border:none;
  }
</style>
<iframe id='frame' src="https://tehflamintaco.github.io/Reverse-Programmer-Notation/RProgN.html?rpn=%27rep%27%20%C2%BA%20%27R%27%20%3D%20%27*%27%20%27s%27%20%3D%20%E2%96%BA%5D%C2%BF%5Ds%5CR%5C1-%5D%7D%5B&input=5">Sorry, You need to support IFrame. Why don't you..?</iframe>
```
> 3 votes

# Answer
# Groovy, 27 characters

```
{1.upto(it){println"*"*it}}

```

Sample run:

```
groovy:000> ({1.upto(it){println"*"*it}})(5)
*
**
***
****
*****
===> null

```
> 3 votes

# Answer
# jq, 19 characters

(18 characters code + 1 character command line option.)

```
range(1;.+1)|"*"*.

```

Sample run:

```
bash-4.3$ jq -r 'range(1;.+1)|"*"*.' <<< 5
*
**
***
****
*****

```

On-line test (Passing `-r` through URL is not supported – check Raw Output yourself.)
> 3 votes

# Answer
# Charcoal, 5 bytes

```
Ｇ↓→Ｎ*

```

It's the same length as Jelly, which is really bad for an ASCII-art oriented language. At least it's readable, I guess

### Explanation

```
Ｇ      Polygon
 ↓→     Down, then right
   Ｎ   Input number
     *  Fill with '*'

```
> 3 votes

# Answer
# Lua, 36 bytes

```
for i=1,...do print(("*"):rep(i))end

```

Takes input from the command line.
> 3 votes

# Answer
# TI-Basic, ~~28~~ 22 bytes

```
Prompt A
"*
For(B,1,A
Disp Ans
Ans+"*
End

```
> 3 votes

# Answer
## Haskell, 32 bytes

```
unlines.(`take`iterate('*':)"*")

```

The expression `iterate('*':)"*"` generates the infinite list `["*","**","***","****","*****",...]`. The function then takes the first `n` elements and joins them with newlines.

The more direct

```
concat.(`take`iterate('*':)"*\n")

```

is one byte longer.
> 3 votes

# Answer
# RProgN, 42 Bytes, Competing only for the Bounty

```
Q L c 's' =
►3'rep'º'R'=]¿]s\R\1-]} [

```

> The length of the script is used as the character code for \*.

Try it Online!
> 3 votes

# Answer
# Perl, ~~83~~ 76 bytes (no asterisk)

```
print substr((split("\n",`perldoc perlre`))[55],48,1)x$_."\n"foreach(1..<>);

```

(Faster version for large input, 83 characters):

```
$r=`perldoc perlre`;print substr((split("\n",$r))[425],11,1)x$_."\n"foreach(1..<>);

```

Explanation: The statement `perldoc perlre` executes the shell command to display the Perl documentation on regular expressions, which contains an asterisk as the 11th character on line 425. Split the resulting output by line, then extract that character and print in triangular format.

Edited to save 6 characters by not saving the output of the shell command, and instead just running it every time. It increases the runtime, though, but we only care about bytes, not runtime :) Another byte was saved (for a total of -7) by finding an earlier asterisk in the perldoc output.
> 3 votes

# Answer
# ForceLang, 146 bytes

```
def S set
def G goto
S a io.readnum()
S b 0
label 0
if a=b
G 1
if b
io.writeln()
S b 1+b
S c 0
label b
io.write "*"
S c 1+c
if b=c
G 0
G b
label 1

```
> 3 votes

# Answer
# Python 2, ~~38~~ 37 bytes

There are only 36 characters shown, but a trailing newline is needed to avoid an EOF-related error raised by the interpreter. 1 byte knocked off for Flp.Tkc's observation.

```
for n in range(input()+1):print'*'*n

```

### Output for n=5

```
# leading newline here
*
**
***
****
*****

```

# Python 3, 45 bytes

The actual list comprehension is never assigned or printed, but if it were, it would be full of `None`s, as `None` is the default return value of `print()`.

```
[print('*'*n)for n in range(int(input())+1)]

```
> 3 votes

# Answer
## Underload, ~~15~~ 13 bytes

<sup>-2 or -3 bytes thanks to @ØrjanJohansen</sup>

```
(
)((*)~*:S)^

```

Input is a Church numeral inserted between the `)` and `^` on the second line. For example:

```
(
)((*)~*:S)::*:**^

```

If printing a leading newline is allowed, the following solution works by ommiting the `~`, for 12 bytes:

```
(
)((*)*:S)^

```
> 3 votes

# Answer
# APL (Dyalog Unicode), 7 bytes<sup>SBCS</sup>

```
(,⍕⊢)⌸⍳

```

Try it online!
> 3 votes

# Answer
## `n`, ~~6~~ 4 bytes

```
'**M

```

## Explanation

```
   M           % Map every item in the implicit input with...
               % (There's an implicit range from 1)
'**            % asterisks input times

n % Join the result with a (n)ewline

```

# How do I use the `n` flag?

`... W.py filename.w [input-list] n`
> 3 votes

# Answer
# GolfScript, 11 bytes

```
~,{)"*"*n}%

```

Try it online!

### Explanation:

```
~,                  Create list [0...input-1]
  {      }%         Map over list:
   )"*"*n           Increment, push that many "*"s, push newline

```
> 3 votes

# Answer
# Flurry, 88 bytes

```
{}{()[<><<>()>({})]({}{(){}(((<><<>()>){})[{}{<({}){}>}])}{<(<({})(<({}){}>){}>){}>})}{}

```

Can be run with the interpreter as follows:

```
$ ./Flurry -bnn -c "$pgm" 5
*
**
***
****
*****

```

This is heavily based on my answer to "Print a 10 by 10 grid of asterisks". In particular, I'm reusing my derivations of `succ`, and `push_star`, and the number `10`.

`push_star` is a function that pushes 42 to the stack and returns its argument unchanged:

```
push_star := {(){}(((<><<>()>){})[{}{<({}){}>}])}

```

A function that takes a number `n` and pushes 42 to the stack `n` times, then pushes 10, and returns `n+1`:

```
push_row = λn. (n push_star (); push 10; succ n)
         = λn. (push (n push_star 10); succ n)
         = λn. K (succ n) (push (n push_star 10))
         = λn. K (succ (push n)) (push (pop push_star 10))
        := {  () [succ (    {})] (      {}  push_star 10)}
        := {  () [succ (    {})] (      {}  push_star {<(<({})(<({}){}>){}>){}>})}
        := {  () [succ (    {})] (      {}  {(){}(((<><<>()>){})[{}{<({}){}>}])}{<(<({})(<({}){}>){}>){}>})}
        := {()[<><<>()>({})]({}{(){}(((<><<>()>){})[{}{<({}){}>}])}{<(<({})(<({}){}>){}>){}>})}

```

The number 1:

```
1 = λf n. f n
  = λf. f
 := {  {} }

```

Pop a number from the stack and apply `push_row` that many times to 1:

```
main = pop push_row 1
    := {}{()[<><<>()>({})]({}{(){}(((<><<>()>){})[{}{<({}){}>}])}{<(<({})(<({}){}>){}>){}>})}{{}}

```

Since popping from an empty stack returns 1, we can replace the final `{{}}` with `{}`, yielding:

```
{}{()[<><<>()>({})]({}{(){}(((<><<>()>){})[{}{<({}){}>}])}{<(<({})(<({}){}>){}>){}>})}{}

```
> 3 votes

# Answer
# tinylisp, 84 bytes

```
(load library
(d Q(q((A)(join(map string(map* repeat-val(repeat-val 42 A)(1to A)))nl

```

Try it online!

# tinylisp, 89 bytes

```
(d P(q((A N)(i(s N 1)(i(disp(string A))A(P(c 42 A)(s N 1)))(string A
(d Q(q((N)(P(q(42))N

```

Try it online!

the length of the library functions makes this surprisingly close to the library based one.
> 3 votes

# Answer
## Racket 47 bytes

```
(for((i(+ 1 n)))(displayln(make-string i #\*)))

```

Ungolfed:

```
(define (f n)
  (for ((i (+ 1 n)))                         ; (i 5) in 'for' produces 0,1,2,3,4
    (displayln (make-string i #\*))))        ; #\* means character '*'

```

Testing:

```
(f 5)

```

Output:

```
*
**
***
****
*****

```
> 2 votes

# Answer
## QBIC, 16 bytes

```
:#*|[1,a|B=B+A?B

```

Explanation:

```
:         Gets a cmd line param as number called 'a'
#*|       Define A$ as '*'
[1,a|     FOR b = 1 to a
B=B+A     Extend B$ with another astrix
?B        Print B$
<FOR LOOP implicitly closed>

```

QBIC's seen a few updates since this answer was posted. This could now be done with these 12 bytes:

```
[:|B=B+@*`?B

```
> 2 votes

# Answer
# PHP, ~~43~~ ~~34~~ ~~31~~ 28 bytes

Note: uses IBM 850 encoding (old favorite reinvented recently)

```
for(;$argn--;)echo$o.=~ı,~§;

```

Run like this:

```
echo 5 | php -nR 'for(;$argn--;)echo$o.=~ı,~§;';echo
> *
> **
> ***
> ****
> *****

```

# Explanation

Iterates from `N` down to 0. Add an asterisk to `$o` for each iteration, then outputs `$o` and a newline.

# Tweaks

* Add an asterisk to `$o` for each iteration, and then output `$o`. Saves 9 bytes
* Combined adding an asterisk to `$o` with outputting, saves 3 bytes
* Saved 3 bytes by using `$argn`
> 2 votes

# Answer
## Pyke, 6 bytes

```
Voh\**

```

Try it here!
> 2 votes

# Answer
# Brain-Flak, 81 bytes

78 bytes but three for the `-A` flag, which enables ASCII output.

```
{(({}[()])<>()){({}[()]<(((((()()()){}())){}{}){})>)}{}((()()()()()){})<>}<>{}

```

Try it online!

Brain-flak isn't the greatest language for ASCII-art, but it still managed to be somewhat short. Ish. Kinda.

Explanation:

```
While True:
{

(
Decrement counter
({}[()])

And move copy to other stack
<>())

Push N '*'s
{({}[()]<(((((()()()){}())){}{}){})>)}

Pop 0
{}

Push newline
((()()()()()){})

Move back to counter
<>

Endwhile
}

Move to other stack
<>

Pop an extra newline
{}

```
> 2 votes

# Answer
# Pyth, ~~10~~ 8 Bytes

thanks to Jakube for helping me shave off the extra 2 bytes!

```
VQ*Np"*"

```

Try it
> 2 votes

# Answer
# Ruby, 27 (or 24) bytes

(Thanks to m-chrzan for pointing out the miscounting.)

Returns a string.

```
->n{(1..n).map{|i|?**i}*$/}

```

the `map` makes an array of strings of `*` of increasing length. The `*$/` takes the array and joins the elements to make a newline-separated string. If an array of strings is acceptable, these three bytes can be saved, scoring 24.

In test program

```
f=->n{(1..n).map{|i|?**i}*$/}
puts f[5]

```
> 2 votes

# Answer
# Jolf, 7 bytes

This time, the builtin didn't let me win. Oh well.

```
―t0jj'*

```

Try it here!

## Explanation

```
―t0jj'*
―t0     pattern: left-corner-base triangle
   j     with <input> height
    j    and <input> width.
     '*  comprised of asterisks

```
> 2 votes

# Answer
# Java 7,~~72~~ 70 bytes

*Thanks to @kevin for shave it off by 2 bytes.*

```
String f(int n,String s,String c){return n<1?c:f(--n,s+"*",c+s+"\n");}

```

### Output

```
*
**
***
****
*****
******

```
> 2 votes

# Answer
# C++, 78 bytes

I don't know how there are 2 C++ answers that don't just do it with for loops. Very short and sweet this way:

```
void T(int n){for(int i=1;i<=n;i++){for(int j=0;j<i;j++)cout<<'*';cout<<'\n';}}

```

## Full program

```
#include <iostream>

using namespace std;

void T(int n)
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < i; j++)
            cout << '*';
        cout << '\n';
    }
}

int main()
{
  T(5);
}

```

Edit: it is unclear to me whether to count the `#include<iostream>`, `using namespace std`, and/or `std::whatever` in calls. C/C++ answers all over this site seem to use both, and for the most part no one seems to care except for the occasional comment. If I need the `std::`, then +10. If I need the `#include<iostream>`, +18 (although GCC allows me to do without the basic includes, so maybe not that one)
> 2 votes

# Answer
# Java, 110 bytes

Not that short, but I really like having empty for loops.

```
String f(int n){String s="";for(int i=0;i<n;i++,s+=new String(new char[i]).replace("\0","*")+"\n"){}return s;}

```
> 2 votes

# Answer
# GameMaker Language, 68 bytes

```
a="*"for(i=2;i<=argument0;i++){a+="#"for(j=0;j<i;j++)a+="*"}return a

```
> 2 votes

# Answer
# Prolog, ~~60 58~~ 56 bytes

```
g(N):-N<=0,put(*),g(N-1);!.
f(N):-N<=0,f(N-1),g(N),nl;!.

```

I'm not that familiar with Prolog, but I just gave it a shot. I'm sure it can be a lot shorter.

Put the code into a file, then load that file into swipl and run `f(25).` (or some other number).

*EDIT:* quotes can be left out in put statement
*EDIT 2:* changing `=:=` to `<=` saves 2 bytes. I tried inverting it, but that'd make it wait for a return for some reason.
> 2 votes

# Answer
# Elixir, 81 bytes

```
&Enum.reduce(Enum.to_list(1..&1),"",fn(x,r)->r<>String.duplicate("*",x)<>"\n"end)

```

Anonymous function using the capture operator. `Enum.reduce` will iterate a list (the list is obtained by calling `Enum.to_list` on the range 1..n) and concatenate the return string `r` (which has been initialized with "") with a string made of `x` asterisks and a newline.

Full program with test case:

```
s=&Enum.reduce(Enum.to_list(1..&1),"",fn(x,r)->r<>String.duplicate("*",x)<>"\n"end)
IO.write s.(5)

```

**Try it online on ElixirPlayground !**
> 2 votes

# Answer
> Since the course is taught in C++, I'm eager to see solutions in C++.

# C++, 123 bytes

(the joke here is to deliver a 'pure' c++ answer)

```
#include<string>
class X:public std::string{public:X(int i):std::string(i*(i+1)/2,'*'){for(;i--;)insert(i*(i+1)/2,"\n");}};

```

Test
> 2 votes

# Answer
**Brainfuck, 129 bytes**

I know there's already a shorter answer in brainfuck, however I wanted to create a program which could handle a multi-digit number input rather than either a single-digit input or a single ascii character input unlike the previous one posted.

```
,[>+++[->++++[-<<---->>]<]+>,]<-<<[<<]>>[<[->>++++++++++<<]>>>]+>>++++++++++>>++++++[-<+++++++>]<<<<<[>[->+>>.<<<]>>.<[-<+>]<+<-]

```

This is my first ever brainfuck program and it will work for any input between 0 and the maximum size of a single cell (traditionally 8 bits or 255) entered using the characters '0' to '9' (corresponding to ascii-values 048-057)

**Explanation**

The first part of this program, `,[>+++[->++++[-<<---->>]<]+>,]`, takes the input numbers as char values and removes 48 from each to make them equal to the numbers 0 to 9 rather than the char values of the numbers 0 to 9. It stores these in separate cells with a 1 in between each of them so that the start and end points can be found again.

The second part, `<-<<[<<]>>[<[->>++++++++++<<]>>>]`, consolidates the separate values into one cell. This is why the maximum size of a cell controls how high a number can be.

The third section, `+>>++++++++++>>++++++[-<+++++++>]<<<<<`, is used to set up the other cells needed: one with the number of asterisks per line, one with the code for a linefeed and one with the code for an asterisk. There is also a blank cell left for working with later.

The remainder of the code, `[>[->+>>.<<<]>>.<[-<+>]<+<-]`, is used to:

1. Output as many asterisks as necessary
2. Output a linefeed
3. Reset the value of the cell controlling the asterisks
4. Increment the control cell
5. Decrement the cell with the number until it equals 0
> 2 votes

# Answer
# 05AB1E, 11 bytes

```
'*×.pD¦`r`»

```

Try it online!

**Explanation:** (Prints hourglass)

```
                  Implicit input - 5
'*                Asterisk character - stack = '*'
  ×               Repeat input times - stack = '*****'
   .p             Get prefixes       - stack = ['*', '**', '***', '****', '*****']
     D            Duplicate last element
                  STACK = ['*', '**', '***', '****', '*****'] , ['*', '**', '***', '****', '*****']
      ¦           Remove first element from final list
                  STACK = ['*', '**', '***', '****', '*****'] , ['**', '***', '****', '*****']
       `r`        Reverse 1 list and flatten both
                  STACK = '*****','****','***','**','*','**','***','****','*****'
          »       Join by newlines and implicitly print

```

For input 5, prints:

```
*****
****
***
**
*
**
***
****
*****

```
> 2 votes

# Answer
# C++ 11, 65 bytes

Not including the `include` in the byte count.

```
#include<string>
using S=std::string;S g(int n){return n?g(n-1)+S(n,'*')+'\n':"";}

```

Usage:

```
std::cout << g(n) << std::endl;

```
> 2 votes

# Answer
# SQL, 153 Bytes

Golfed:

```
CREATE PROCEDURE P @n INT AS BEGIN DECLARE @a INT;SET @a=0;DECLARE @o VARCHAR(1000);SET @o='*'WHILE @a<@n BEGIN PRINT @o;SET @o=@o+'*'SET @a=@a+1;END;END

```

Ungolfed:

```
CREATE PROCEDURE P
@n INT
AS
BEGIN
DECLARE @a INT;
SET @a=0;
DECLARE @o VARCHAR(1000);
SET @o='*'
WHILE @a<@n
    BEGIN
    PRINT @o;
    SET @o=@o+'*'
    SET @a=@a+1;
END;
END

```

Testing:

```
EXEC P '6'

```

Output:

```
*
**
***
****
*****
******

```
> 2 votes

# Answer
# Dip, ~~6~~ 5 bytes

```
`**En

```

*-1 byte thanks to Oliver*

**Explanation:**

```
`**    Push "*" repeated input times
   E   Prefixes
    n  Join by newlines

```
> 2 votes

# Answer
# Crystal, 31 bytes

`n=5;(1..n).each{|x|puts "*"*x}`

Output:

```
*
**
***
****
*****

```

Really demonstrates the beauty of Crystal/Ruby. `n` is the integer input, `(1..n)` is an inclusive range from `1` to `n` (`[1, n]`). `.each` is a method on Range that runs the provided block for every integer in the range.
> 2 votes

# Answer
# python3, ~~58~~ 57 bytes

```
print('\n'.join(['*'*(p+1)for p in range(int(input()))]))

```

Ungolfed:

```
rownums = int(input())
output = []
for i in range(rownums):
    currrow = "*" * (i+1) # 'i' * 5 == 'iiiii'
    output.append(currrow)
print('\n'.join(output))

```
> 2 votes

# Answer
# C, 88 bytes / 53 bytes

Using C89.

`g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}main(int a,char**v){g(atoi(v[1]));}`

With whitespace for clarity:

```
g(a) {
    a && g(a-1);
    a<2 || puts("");
    while (a--) putchar('*');
}
main(int a, char** v) {
    g(atoi(v[1]));
}

```

Without main, this function is 53 bytes:

`g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}`
> 2 votes

# Answer
# Common Lisp, SBCL, ~~69~~ ~~66~~ ~~61~~ ~~45~~ ~~44~~ 41 bytes

full program:

```
(dotimes(i(read))(format t"~v{*~}*
"i 1))

```

### Explanation

```
(dotimes(i(read)) <-- loop from i=0 to i=INPUT-1
(format t"~v{*~}*
"i 1)) <-- loop, displaying i+1 asterisks per line

```

Ideas for improvement are welcomed.
> 2 votes

# Answer
# SmileBASIC, 30 bytes

```
INPUT N
FOR I=1TO N?"*"*I
NEXT

```
> 2 votes

# Answer
**Haskell 36 Bytes**

Here is a version using map.

```
f="*":map('*':)f;g=unlines.(`take`f)

```

Input `g 10` Output `"*\n**\n***\n****\n*****\n******\n*******\n********\n*********\n**********\n"`

Alternatives of interest might be:

38 Bytes

```
g n=id=<<scanl(\x y->'*':x)"*\n"[2..n]

```

38 Bytes

```
f="*\n":map('*':)f;g n=id=<<(n`take`f)

```

36

```
g n=id=<<(take n$iterate('*':)"*\n")

```
> 2 votes

# Answer
# k, 18 bytes

```
{-1@(1+!x)#\:"*";}

```

Explanation:

```
-1@ // prints to console

1+!x //returns list from 1 to x (implicit input)

#\:  //for each item in the prefixed list, "take" this many

"*" //asterisk string

```
> 2 votes

# Answer
# Perl 6, 17 bytes

```
put(\*x++$)xx get

```

Full program that prints to stdout.
How it works:

```
    \*             # a Capture object that stringifies to the asterisk,
      x            # string-repeated by
       ++$         # a counter that starts at 1,
put(      )        # and printed followed by a newline.
           xx get  # Do all of that n times.

```

Invokes the `put` statement *n* times, each time printing the asterisk repeated by the counter variable `++$`.

---

# Perl 6, 21 bytes

```
{.put for \*Xx 1..$_}

```

A lambda that prints to stdout.
How it works:

```
{                   }  # A lambda.
          \*           # A Capture object that stringifies to the asterisk.
               1..$_   # Range from 1 to n.
            X          # Cartesian product of the two,
             x         # with the string repetition operator applied to each result.
 .put for              # Iterate over the strings, and print each followed by a newline.

```
> 2 votes

# Answer
# Bash \+ Unix utilities, 26 bytes

```
seq -f10^%f-1 $1|bc|tr 9 *

```

**Output to stderr should be ignored.**

Try it online!

The code above works on TIO since the working directory there has no visible files. If this needs to run in a directory that contains a visible file, change `*` to `\*` at the cost of one byte (27 bytes):

```
seq -f10^%f-1 $1|bc|tr 9 \*

```
> 2 votes

# Answer
# Japt `-R`, ~~8~~ 4 bytes

```
õ_î*

```

Try it online!

4-byte alternative:

```
°Tî*

```

Try it online
> 2 votes

# Answer
# Terrapin logo, 67 bytes

```
to a :a
make "b 1 repeat :a[repeat :b[type "*]make "b b+1 pr "]
end

```
> 2 votes

# Answer
# k, ~~16~~ 12 bytes

4 bytes removed thanks to ngn! :)

```
{`0:,\x#"*"}

{          } /function(x)
      x#"*"  /reshape "*" by x
    ,\       /scan concatenation through the list
 `0:         /print line by line

```
> 2 votes

# Answer
## K, 16 Bytes

```
 {-1(1+!x)#'"*"};

  {-1(1+!x)#'"*"}10;
*
**
***
****
*****
******
*******
********
*********
**********

```

EDIT BELOW - adding explanation)

```
/Code     ---> explanation (pretend x is 3)
1+!x      ---> Numbers from 1 to 3
1 2 3#"*" ---> Take left many items of right ==> ("*";"**";"***")
-1x       ---> Print x to the console, if x is a list, each item is printed to a new line

example(notice the -1 printed at the bottom).
     -1("*";"**";"***")
     *
     **
     ***
     -1
To silence the output(-1), put a semicolon after the expression e.g.
-1("Hello");
Hello

```
> 2 votes

# Answer
# Röda 0.12, ~~30~~ 29 bytes, non-competing

```
h i{seq 1,i|{|j|print"*"*j}_}

```

This is my first try in this scripting language created by fergusq :D

This is a function. To run, use this:

```
h i{seq 1,i|{|j|print"*"*j}_}

main {
  h(5)
}

```

### Ungolfed

```
h i{                         /* Define a function h with parameter i */
   seq 1,i                   /* Generate a sequence of numbers from 1 to i */
          |{             }_  /*  and pipe it to a for-loop */
            |j|              /*  where j is the number in the sequence*/
               print"*"*j    /*  and print an asterisk duplicated j times*/
}

```
> 2 votes

# Answer
# Excel VBA, 32 Bytes

Anonymous VBE immediate window function that takes input from range `A1` and outputs to the VBE immediate window.

```
For i=1To[A1]:?String(i,42):Next

```
> 2 votes

# Answer
# SNOBOL4 (CSNOBOL4), ~~59~~ 52 bytes

```
	n =input
o	output =o =o '*' lt(size(o),n) :s(o)
end

```

Try it online!
> 2 votes

# Answer
# Canvas, 3 bytes

```
*×］

```

Try it here!

Explanation:

```
  *×］  full program
｛  ］  map over [1..input]
  *×      repeat by *

```
> 2 votes

# Answer
# Wren, 41 bytes

```
Fn.new{|i|(1..i).map{|n|"*"*n}.join("
")}

```

Try it online!

## Explanation

```
Fn.new{|i|                             // New function with the parameter i
          (1..i)                       // Generate a range from 1 to i
                .map{|n|"*"*n}         // Replace the numbers with asterisks
                              .join("
")}                                    // Join with newline

```
> 2 votes

# Answer
# MathGolf, 4 bytes

```
╒⌂*n

```

Try it online or verify some more test cases.

**Explanation:**

```
╒     # Push a list in the range [1, (implicit) input]
 ⌂    # Builtin for the asterisk character "*"
  *   # Map each value to that amount of asterisk characters (similar as in Python)
   n  # And join this list of strings by newlines
      # (after which the entire stack joined together is output implicitly as result)

```
> 2 votes

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

```
int f(int n){for(n&&f(n-1);~n;__builtin_putchar(n--?42:10));}

```

Uses ASCII char codes and builtins to shorten another solution.

Try it online!
> 2 votes

# Answer
# , 8 bytes

```
[\@$&'*'

```

Explanation:

1. `$&'*'`: Reshape `*` according to.

* `$`: Reshape.
* `&`: Bound with (partial application).
* `'*'`: Character literal `*`.

2. `@`: Function composition.
3. `[\`: Each prefix of.

* `[`: Identity.
* `\`: Apply the preceding verb to each prefix of the right argument.
> 2 votes

# Answer
# Vyxal `j`, 3 bytes

```
×*¦

```

Try it Online!

## How?

```
×*¦
×*  # Repeat an asterisk the implicit input amount of times
  ¦ # Prefixes
    # j flag joins on newlines

```
> 2 votes

# Answer
# Gema, 36 characters

```
*=@repeat{*;@append{s;\*}@out{$s\n}}

```

Sample run:

```
bash-4.3$ gema '*=@repeat{*;@append{s;\*}@out{$s\n}}' <<< 5
*
**
***
****
*****

```
> 1 votes

# Answer
# Forth, 39 bytes

Quite simple, with a couple of nested loops. ASCII `42` is an asterisk.

```
: f 0 do I -1 do 42 emit loop CR loop ;

```

**Try it online**

Prints a trailing newline.
> 1 votes

# Answer
# Bash, 35 characters

```
for((;i++<$1;));{ s+=\*;echo "$s";}

```

Sample run:

```
bash-4.3$ bash draw-an-asterisk-triangle.sh 5
*
**
***
****
*****

```
> 1 votes

# Answer
# C++, 108 chars

```
#import<iostream>
main(){int n;std::cin>>n;for(int i=1;i<=n;++i){for(int j=i;j--;)std::cout<<"*";puts("");}}

```

Straightforward.

**Try it online**
> 1 votes

# Answer
# Vitsy, ~~19~~ 16 bytes

Yeah this needs some reducing. I'm out of practice!

```
D1H}\[\['*'O]aO]

(implicit input)
D                 Peek n, push n.
 1                Push 1.
  H               Pop x, pop y, push range(x, y)
   }              Reverse, pop n, reverse, push n.
    \[         ]  Pop n, do bracketed items n times.
      \[    ]     Pop n, do bracketed items n times.
        '*'O      Output the character *.
             aO   Output a newline.

```

Think of it as though I'm iterating through a list (1 through n) and popping out the number of \*s according to the currently selected list item.

Explanation soon.
> 1 votes

# Answer
# Javascript, 71 bytes 48 Bytes, thanks ETHproductions!

```
(n,c)=>{while(c<=n)console.log("*".repeat(c++))}

```
> 1 votes

# Answer
## Befunge93, 31 chars (3 spaces, 8 pure directionals)

```
&>:#v_@
-^  : >$55+,1
,"*"<_^#:-1

```

## Befunge98, 28 chars

```
&>:#v_@
-^  : >$a,1
1,*'<_^#:-

```
> 1 votes

# Answer
## Clojure, 59 bytes

```
#(doseq[m(range 1(inc %))](println(apply str(repeat m\*))))

```

Basically, just uses `doseq` to loop over the range, printing the corresponding number of stars.

It's really unfortunate that the shortest way I've been able to repeat a character in Clojure is `(apply str (repeat m \*))`. That's hardly competitive here. Some good ol' python string multiplication would have been awesome.

Ungolfed:

```
(defn tri [n]
  (doseq [m (range 1 (inc n))]
    (println (apply str (repeat m \*)))))

```

Should be fairly self-explanatory.
> 1 votes

# Answer
## Ruby, 29 bytes

```
->n{n.times{|i|puts'*'*i+?*}}

```

Call with `->n{n.times{|i|puts'*'*i+?*}}[number]`.
> 1 votes

# Answer
# Ruby, 32 bytes

```
1.upto($*[0].to_i){|i|puts"*"*i}

```

The `$*` is an array of arguments.

`foo.rb 5` will print the following:

```
*
**
***
****
*****

```
> 1 votes

# Answer
# Excel VBA, 109 bytes

This function returns to cell, requires text wrapping be turned on.

```
Function a(b)
For i = 1 To b
For c = 1 To i
d = "*" & d
Next c
a = a & d & Chr(10)
d = ""
Next i
End Function

```

**99 Bytes** \- Alternative that runs as a function but prints to immediate.

```
Function f(b)
For i = 1 To b
For c = 1 To i
Debug.Print "*";
Next c
Debug.Print
Next i
End Function

```

**94 Bytes** \- One more that is just a sub with hard coded value, prints to immediate.

```
Sub k()
r = 5
For i = 1 To r
For c = 1 To i
Debug.Print "*";
Next c
Debug.Print
Next i
End Sub

```
> 1 votes

# Answer
### PHP, ~~66~~ 58 bytes

Just a simple loop, really.

~~I'm new to golfing, so might not be the shortest way.~~

```
for($i=fgets(STDIN);$x++<$i;)echo str_repeat("*",$x)."\n";

```

https://eval.in/658719

<sup>Thanks to manatwork for byte-saving.</sup>
> 1 votes

# Answer
# VBA, 84 bytes

taking advantage of recursive coding. it generates x times * as the line/round

```
Function f(x)
If x<=1 Then f="*" Else f=f(x-1) & vbCrLf & String(x,"*")
End Function

```

results:

```
?f(10)
*
**
***
****
*****
******
*******
********
*********
**********
?f(2)
*
**

?f(5)
*
**
***
****
*****

```
> 1 votes

# Answer
# Common Lisp (Lispworks), 71 bytes

```
(defun f(n)(dotimes(i n)(dotimes(j(1+ i))(format t"*"))(format t"~%")))

```

Usage:

```
CL-USER 170 > (f 5)
*
**
***
****
*****
NIL

```

Ungolfed:

```
(defun f (n)
  (dotimes (i n)
    (dotimes (j (1+ i))
      (format t "*"))
    (format t "~%")))

```
> 1 votes

# Answer
# MoonScript, 31 bytes

```
(n)->for i=1,n
 print "*"\rep i

```

Sample call:

```
_ 5

```
> 1 votes

# Answer
**F#, 114 chars**

```
[<EntryPoint>]
let main a =
 for i = 1 to System.Int32.Parse(a.[0]) do
  printfn "%s" <| String.replicate i "*"
 0

```
> 1 votes

# Answer
# Scala, ~~44~~ 30 bytes (~~51~~ 45 without asterisk, 41 for hourglass)

## With asterisk in code (30 bytes):

```
(i:Int)=>(i to(1,-1))map("*"*) //create a range from i to 1 and map each number to that number of asterisks

```

## Without asterisk (45 bytes):

```
(i:Int)=>(i to(1,-1))map(((41+1).toChar+"")*) //same as above, but without a literal asterisk

```

## Without asterisk and easy ways of calculating 42 (57 bytes):

```
(i:Int)=>(i to(1,-1))map(((math sqrt("7G"##)).toChar+"")*)

```

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for `*`

## Hourglass:

```
(& :Int)=>((&to(1,-1))++(2 to&))map("*"*)

(& :Int)=>        //define an anonymus function with an int parameter called &
  (
    (& to (1,-1))   //a range from & to 1, counting by -1, aka downwards
    ++              //concat
    (2 to&)         //a range from 2 to &
  )
  map(              //map each number to
    "*" *             //the string "*" repeated x times
  )

```
> 1 votes

# Answer
# Braingasm, 27 bytes

Braingasm is a brainfuck variant with just a few more instructions and options. And this task would've been so much easier if I had bothered implementing that *as many times as the value in the current cell* thing yet..

```
;[->+[->+42.<]10.>[-<+>]<<]

```

Here's how it works:

```
;                           Read an integer from stdin and write it to cell#1
 [                        ] While the value of cell#1 is not zero,
  ->+                    <    substract one from cell#1 and add one to cell#2.
     [->+   <]                Each time, do the same between cell#2 and cell#3,
         42.                    but also print an asterix on the way.
              10.             Then print a newline.
                 >[-<+>]<     Move the value from cell#3 back to cell#2

```
> 1 votes

# Answer
**Python 3, 196 Bytes**

```
import contextlib as b,io;q=io.StringIO()
with b.redirect_stdout(q):import this
n=int(input());c=q.getvalue()[655];print(''.join([''.join([c for z in range(n)][:i+1])+'\n' for i in range(n)]))

```

This is probably counted as a cheat, but it uses the asterisk character in the `import this` string rather than explicitly writing an asterisk in the program code. It also doesn't use any asterisk multiplication operators. It temporarily rerouts stdout so as not to print the Zen of Python when run.
> 1 votes

# Answer
# 05AB1E, 8 bytes

```
TžQè×.p»

```

Explanation coming soon
> 1 votes

# Answer
# Element, 16 bytes

```
_'[1+'[\*`]\
`"]

```

Try it online!

**Explanation:**

This is a pretty simple nested-loop approach. Let `N` represent the newline in the source code.

```
_'[1+'[\*`]\N`"]
_'                take input and move it to the control stack
  [            ]  a FOR loop, each iteration = 1 line of output
  [1+          ]  increment the top of the stack, as a counter
  [  '         ]  move that value to the control stack
  [   [   ]    ]  another FOR loop, for the current line
  [   [\*`]    ]  output a literal asterisk
  [        \N` ]  output a literal newline
  [           "]  move the counter from control to main stack

```
> 1 votes

# Answer
# C++, 63 bytes

```
void s(int n){if(n)s(n-1),cout<<setfill('*')<<setw(n+1)<<"\n";}

```

Usage:

```
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    s(5);
}

```

Overrides the filling character (which is usually a space), and outputs an empty string (or actually a newline).

One weird thing about this code is the usage of `if (...)` \- I cannot find a way to replace it by a conditional operator `... ? ... : ...`.
> 1 votes

# Answer
# Swift 3, 86 bytes

```
for i in 1...Int(CommandLine.arguments[1])!{print(String(repeatElement("*",count:i)))}

```

Yuck. If I can drop the Int and String initializers I might be able to get this shorter than Java. Open to any optimizations.

Ungolfed:

```
import Foundation

guard CommandLine.argc > 1, let a = Int(CommandLine.arguments[1]) else {
    fatalError("Invalid or nonexistent argument")
}

for i in 1...a {
    print(String(repeatElement("*", count: i)))
}

```

Usage:

```
➜ ~ swift asterisk.swift 5
*
**
***
****
*****

```
> 1 votes

# Answer
## \>\<\>, 47 bytes

```
<v[1:$-1;!?:$+10
0\:&
$>:@=?v1+&:&"*"o
0f]oa~<.

```

Try it here!

This was fun to write, though a bit more bytes than I expected.
> 1 votes

# Answer
# Sinclair ZX81/Timex TS1000/1500, 117 bytes (listing)

```
1 PRINT "NUMBER OF * TO SHOW?"
2 INPUT A
3 IF A<1 THEN STOP
4 LET J=A/A
5 FOR I=1 TO A
6 FOR X=1 TO J
7 PRINT "*";
8 NEXT X
9 LET J=J+1
10 PRINT
11 NEXT I

```

Note that because the screen scroll isn't handled in this program listing, you may only enter a number between 0 and 22 because as soon as the ZX81 hits the bottom of the screen it will halt the program. You can see the missing * by using `CONT` when this happens, but also note that the ZX81 only has 32 columns text by default in BASIC.
> 1 votes

# Answer
## SQL, 80 bytes

```
DECLARE @i INT=1,@ INT=5WHILE @i<>@ BEGIN PRINT REPLICATE('*',@i)SET @i=@i+1 END

```

ungolfed:

```
DECLARE @index INT=1,
        @rows INT=5

WHILE @index<>@rows
BEGIN
    PRINT REPLICATE('*',@index)
    SET @index=@index+1
END

```
> 1 votes

# Answer
# Rebol, 32 bytes

```
loop do input[print append{}"*"]

```

Ungolfed:

```
loop do input [
    print append {} "*"
]

```
> 1 votes

# Answer
# AutoHotkey, 28 bytes

```
Loop,%1%
Send,{* %A_Index%}`n

```

`%1%` is the first argument passed in
`%A_Index%` is the current iteration in the loop
`Send` sends a keystroke multiple times if it's followed by a number
> 1 votes

# Answer
# dc, 33 bytes

```
?sa0[1+d1F6r^3C*1EF/PAPdla>x]dsxx

```

Input on stdin, output on stdout.

Try it online!
> 1 votes

# Answer
# Forte, 101 bytes

```
1INPUT0
2LET4=(0*(0+1))*5
4END
6PUT42:LET7=6+1
7LET6=6+10
8PUT10:LET9=((9+9)+14)-3:LET3=8+5
3LET8=9-1

```

Try it online!

I've been wanting to try Forte for a while, and this seemed like a fine challenge for it. It was quite an effort writing the program, then golfing it and making it fit in one-digit numbered lines. It was also quite fun :) Kudos to ais523 for inventing this and many more incredible languages.

Since I'm in the mood I'll write an explanation in details, covering also the basis of the language.

### Explanation

First, a very brief introduction for those who don't know this language, you can find the full specification and guide on its esolang page.

The syntax of Forte is similar BASIC, with line numbers prepended to each line, only that in Forte you dont `GOTO 10`, you make 10 come to you!

With the command LET, you can assign a number to... another number. If the command `LET 10=20` is executed, from now on every time the number 10 is referenced, directly or indirectly (5+5 counts too), it is replaced by 20 instead. This affects line numbers too, so if we were on line 19 when executing that instruction, the next line to be executed will be our old line 10, now line 20.

Now, the actual code (with spaces added for clarity):

```
1 INPUT 0

```

This is practically `LET 0=<a number taken from stdin>`, in this program `0` is used like a variable, and only in line number 2

```
2 LET 4=(0*(0+1))*5
4 END

```

Line 4 is the one that terminates the program, so we want to put it at the position where we are done printing asterisks. How many of them do we need to print, though? As fitting for a "draw a triangle" challenge, the answer is given by triangular numbers!

The formula to calculate the nth triangular number is `n*(n+1)/2`. We will print an asterisk every 10 lines, so we multiply it by 10 and get `n*(n+1)*5`. Use `0` instead of `n`, add parentheses for every operation (always mandatory in Forte), and you get line 2.

```
6 PUT 42:LET 7=6+1
7 LET 6=6+10

```

Here we print the asterisks. The ASCII code for `*` is 42, so you get what `PUT 42` does. The colon separates multiple instructions on the same line, so we then execute `LET 7=6+1`. What use do we have in redefining 7 as 6+1? Isn't it the same thing? Let's see what happens next.

Line 7 redefines `6` as `6+10`, so `16`. Ignoring for a moment the rest of the code, this means that when we reach line 16 we will print another asterisk, and then redefine `7` as `6+1`. But now `6` is `16`, so we are redefining it as `16+1`! Line 7 is now line 17 and is the next one to be executed, changing `6` to `6+10`, which means changing `16` to `16+10`, so on line 26 we will print another asterisk, and so on.

Since in Forte a line cannot change its own number, this is the simplest structure for a loop, two lines changing each other's numbers repeatedly. I know this can be quite confusing, but that's kind of the point of the whole language ;)

```
8 PUT 10:LET 9=((9+9)+14)-3:LET 3=8+5
3 LET 8=9-1

```

Ok, that line 3 put here may seem out of place, but in Forte line order doesn't matter, only line numbering. I've chosen to put this line at the end because this pair of lines forms again a cycle, redefining each other's numbers, so it's easier to see them together. Moreover, the first time line 3 is executed (when 3 is still equal to 3 and nothing else), it has no effect on the program, redefining `8` as `8`.

As you probably have guessed `PUT 10` prints a newline, then the hard part comes. We want each line to have one more asterisk than the one before, so to know where to put the next newline we need to know where the previous one was. To do this, we use another "variable": the number `9`. In practice, when we are about to print a newline on line 8, line 3 will be positioned (near) where the previous newline was printed, we'll use it to calculate where the next newline must be printed and move `9` (near) there. (Remember that line 8 can't move itself). Then we move line 3 a bit further than the current position, and use it to move line 8 to our `9`.

These three numbers (`3`,`8`, and `9`) were chosen in order not to conflict with any other redefinition of a number, and to be easy to use together (since neither `5` nor `1` will ever be redefined by this program we can do `LET 3=8+5` and `LET 8=9-1`).

All of these numbers will always be redefined as themselves+10n. This means that `8` will only ever be redefined to numbers ending with an 8 (28,58,98...). This same property is valid for any other number redefinintion in this program (except `0`), because this helped greatly my reasoning while writing the code (if you are crazy enough you can try to golf some bytes by using a smaller step, but I doubt there is much room for golfing without completely changing approach).

So, the actual difficult part of this program: `LET 9=((9+9)+14)-3`. This operation can be better explained if expanded to `LET 9=(9+(9-(3-4)))+10`, where 4 and 10 represent their respective actual numerical values (in the code they are grouped as 14, 4 wouldn't actually be usable because it was redefined in line 2). As we said before `3` is still placed near the previous newline; we subtract 4 from it to get the previous position of `9` (if `3` is 63, our previous `9` was 59), then we compute the difference between the current and the previous `9` to know how many program-lines have passed since the last newline was printed. We add this value to the current `9`, plus 10 because the next time we will want to print one more asterisk. Our `9` is now where we want to print the next newline, so we move `3` to the current position, it will then move `8` to where it's needed, just before `9`.

Phew, that was long. And hard. <sub><sup>No dirty jokes, please</sup></sub>
> 1 votes

# Answer
## Perl 6 (27)

```
{.say for '*' <<x<<(1..$_)}

```
> 1 votes

# Answer
# tcl, 39

```
time {puts [string repe * [incr i]]} $n

```

# demo

~~tcl, 46
```
while {[incr i]<=$n} {puts [string repe * $i]}

```
demo~~
> 1 votes

# Answer
# JavaScript (ES6), 44 bytes

```
n=>[...Array(n)].map(_=>s+="*",s="").join`
`

```

If outputting as an array is permitted then subtract 8 bytes.

```
n=>[...Array(n)].map(_=>s+="*",s="")

```

---

## Try it

```
f=
n=>[...Array(n)].map(_=>s+="*",s="").join`
`
oninput=_=>o.innerText=f(+i.value)
o.innerText=f(i.value=5)
```

```
<input id=i min=1 type=number><pre id=o>
```
> 1 votes

# Answer
# Excel VBA, 37 Bytes

Anonymous VBE immediate window function that takes input from cell `[A1]` and outputs to range `[B:B]`

```
[B1].Resize([A1])="=Rept(""*"",Row())

```
> 1 votes

# Answer
# RProgN 2, 5 bytes

```
²`**S

```

Outputs a stack of strings.

## Explained

```
²`**S
²       # Define the function with the next two concepts, `* and * in this case.
    S   # Create a stack from 1 to the input, and execute the previous function on each element.
   *    # Multiply the element by
 `*     # The string "*", which repeats it. Output is implicit.

```

Try it online!
> 1 votes

# Answer
# 8th, 38 bytes

**Code**

```
( ( "*" . ) swap times cr ) 1 rot loop

```

**SED** (Stack Effect Diagram) is: `n --`

**Example**

```
ok> 5 ( ( "*" . ) swap times cr ) 1 rot loop
*
**
***
****
*****

```
> 1 votes

# Answer
# J, 11 Bytes

```
$&'*'@>:@i.

```

Includes trialing spaces on every line.

### Explanation:

```
$&'*'@>:@i.    | Full program
     @  @      | Verb conjunction characters, make sure it isn't executed as a hook
         i.    | Integers 0 to n-1
      >:       | Increment (Integers 1 to n)
$&'*'          | Reshape the array '*' to the size of each item by repeating it cyclically

```

Note that normally the dyadic ranks of `$` are `1 _`, so that `$&'*' 1 2 3` would create a 1 by 2 by 3 array of `'*'`s. However, the `@` cunjunction ensures that `$&'*'` is applied to each cell of it's argument.
> 1 votes

# Answer
# Japt `-R`, 4 bytes

```
õç'*

```

Try it here
> 1 votes

# Answer
# Julia 0.6, 13 bytes

```
n->"*".^(1:n)

```

`^` is used for exponentiation and string repeating in Julia. This follows from the choice of '\*' for string concatenation, which was chosen over '+' because addition is supposed to be commutative, and string concatenation is not. A function or operator preceded by `.` is "broadcasted", which in this case mean it is applied elementwise.

Outputs an array of strings. Depending on how the rules are interpreted it may need `println.("*".^(1:n))` (23 bytes, meets any interpretation) or `display("*".^(1:n))` (22 bytes, prints exact desired output plus an additional line about the array type) or `"*".^(1:x).*"\n"` (19 bytes, array of strings with newlines). Example of each in TIO.

Try it online!
> 1 votes

# Answer
# Windows batch, 69 bytes

```
@set v=
@for /l %%G in (1,1,%1)do @call set v=*%%v%%&call echo %%v%%

```

Just putting an extra asterisk after each line.
> 1 votes

# Answer
# brainfuck, 42 bytes

```
++++++++++<<,[>>[>]>--[<+>++++++]<-[.<]<-]

```

Try it online!

Takes the number as the char code of the input. Add two to avoid using negative cells, four to avoid wrapping.

### How It Works:

```
Tape Format:  Input 0 10 * * * *...
++++++++++ Creates the newline cell
<<, Gets input
[ While input
 >>[>] Go to the end of the line of asterisks
 >--[<+>++++++]<- Add an asterisk to the end of the line
 [.<] Print the line including the newline
 <- Subtract one from the input
]

```
> 1 votes

# Answer
# Pyt, 17 bytes

```
←ř↔0⇹Á`⑴67**Ƈǰƥłŕ

```

Explanation:

```
←                             Get input
 ř↔                           Push [input,input-1,...,1] onto stack
   0⇹                         Push 0, and flip the top two items on the stack
     Á                        Push contents of array onto stack
      `         ł             While top of stack is not 0, loop:
       ⑴                     Create an array of 1s with length equal to the top of the stack
         67**                 Multiply each element in the array by 42
             Ƈǰƥ              Convert to ASCII, join, and print; if top of stack is 0, exit loop
                 ŕ            Pop the 0

```

Try it online!
> 1 votes

# Answer
# Stax, 4 bytes

```
m'**

```

Run and debug it
> 1 votes

# Answer
# Noether, 14 bytes

```
I("*"i1+*P?!i)

```

**Try it online**
> 1 votes

# Answer
# Keg, `-pn`, 8 bytes

```
Ï^⑷`*`*,

```

Try it online!

## Explanation

```
Ï^

```

In the first part of the program, we push a range from `0` to `n` onto the stack. Then we reverse it because otherwise, the triangle is upside down.

We then start a mapping to the entire stack with the following:

```
    `*`*,

```

Which says to multiply the string `*` by the number being mapped and print it.
> 1 votes

# Answer
# Erlang (escript), 50 bytes

```
s(0)->"";s(N)->s(N-1)++string:copies("*",N)++"~n".

```

Try it online!

## Explanation

```
s(0)->"";    % If the current item is 0, return the empty string.
s(N)->       % Otherwise:
s(N-1)       % Return the N-1 string.
++string:copies("*",N).
             % Append "*" N times.
++"~n"       % Append a newline.

```
> 1 votes

# Answer
# Powershell, 24 bytes

```
1.."$args"|%{$a+="*";$a}

```
> 1 votes

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

```
#include<ios>
int f(int n){for(n&&f(n-1);~n;putchar(n--?42:10));}

```

Including the `#include` in the byte count.

Try it online!
> 1 votes

# Answer
# Add++, 11 bytes

```
L,R"*"€*BFn

```

Try it online!

A function that returns the string given an argument \\$n\\$.

A full program is 17 bytes:

```
y:?
Ey,x:"*",*i,O

```

Try it online!

## How they work

```
L,		; Define "anonymous" function
		; It takes one argument, e.g	5
	R	; Range			STACK = [[1 2 3 4 5]]
	"*"	; Push "*"		STACK = [[1 2 3 4 5] "*"]
	€	; For each i:
	 *	;   Repeat "*" i times	STACK = [["*" "**" "***" "****" "*****"]]
	BF	; Flatten		STACK = ["*" "**" "***" "****" "*****"]
	n	; Join by newlines	STACK = ['*\n**\n***\n****\n*****']
		; Return the top value

```

```
y:?		; y = input()
Ey,		; for i in range(y):
	x:"*",	;   x = "*"
	*i,	;   x *= i
	O	;   print(x)

```
> 1 votes

# Answer
# Thunno `d`, \\$9\log\_{256}(96)\approx\\$ 7.41 bytes

```
R{1+'**ZK

```

Attempt This Online! The slight misallignment on the third line of output is just ATO's formatting.

**Explanation:**

```
R{1+'**ZK   # Implicit input
R{          # Loop through range(0, input)
  1+        #  Add one
      *     #  Multiply this
    '*      #  With the string "*"
       ZK   #  Print
            # The d flag stops the implicit print at the end

```
> 1 votes

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


title: Write some Random English

text:
# Question
Title: Write some Random English
# Your Goal:

Given an odd integer input `n` greater than 1, generate a random *English word* of length `n`. An English word is one in which the **odd** (1-based) indices are **consonants** and the **even** (1-based) **indices** are vowels, the vowels being `aeiou`.

## Random

For the purposes of this challenge, you are to sample from the vowels and consonants uniformly, with replacement. In other words, each possible English word must be equally likely to appear as an output.

# Example Inputs/Outputs

```
3 -> bab, tec, yiq
5 -> baron, nariz, linog
7 -> murovay, fanafim

```

**Winner:**

Winner is the Lowest Byte Count.

# Answer
> 2 votes
# Jelly, ~~9~~ 8 bytes

```
ØḄØẹḂ?X)

```

*-1 byte thanks to @Steffan*

Try it online!

Explanation:

ØḄØẹḂ?X)  # main link taking an integer

       )  # over the list [1..n]
     ?    # if
    Ḃ     # n modulo 2 is truthy
ØḄ        # yield the consonants
  Øẹ      # otherwise the vowels
      X   # get a random letter from that
```
</code></pre>

# Answer
> 5 votes
# 05AB1E, 14 11 bytes

-3 bytes thanks to Kevin Cruijssen

```
EžN¸žMšNèΩJ

```

Try it online!

# Answer
> 5 votes
# Plain English, 485 bytes

```
To add any vowel to a string:
Pick a letter of the alphabet.
If the letter is any vowel, append the letter to the string; exit.
Repeat.

To add any consonant to a string:
Pick a letter of the alphabet.
If the letter is any consonant, append the letter to the string; exit.
Repeat.

To make a random string given a length:
If a counter is past the length, exit.
Add any consonant to the random string.
If the counter is past the length, exit.
Add any vowel to the random string.
Repeat.

```

What better way to write some random English than by using Plain English? I have applied a moderate level of golfing to this code; certain things could be shortened, but it would make this less legible, which would be a shame.

The reason I have defined three routines is because nested loops are forbidden in Plain English, so inner loops must be factored into separate routines.

Parameters and local variables are written as "a string" or "a length" (for example). These are subsequently referred to as "the string" and "the length." If you need to refer to more than one string, you could for example introduce "another string" and refer to it with "the other string." You may also name them whatever you want: "a random string" and refer to it either as "the random" or "the random string."

All arguments are passed by reference; even numbers. To output from a routine, you just modify the arguments. Then you simply refer to the object returned by the routine in the same way as you refer to parameters. For example, to use the routine defined above to output a random English word, you could:

```
To run:
Start up.
Make a random string given 5.
Write the random string on the console.
Wait for the escape key.
Shut down.

```

"To run:" is a special routine that signifies the starting point of the program. When added to the other three routines, this results in a program which will show something similar to the following when compiled and run:

# Answer
> 3 votes
# Perl 5, 69 bytes

```
say map{([a,e,i,o,u],[grep!/[eiou]/,b..z])[$_%2][rand$_%2*16+5]}1..<>

```

Try it online!

# Answer
> 3 votes
# JavaScript (Node.js), 89 bytes

```
f=(n,b)=>(b?"aeiou":"bcdfghjklmnpqrstvwyxz")[~~(Math.random()*(b?5:21))]+(--n?f(n,!b):"")

```

Try it online! (includes tests)

Takes `n` as length and `b` as whether to return vowel or consonant, default consonant.

Returns consonant or vowel based on `b`, decrements `n` and recurses with opposite `b` value.

# Answer
> 2 votes
# Stax, 10 bytes

```
ÇÅφ⌠↑Ñ°↕Yx

```

Run and debug it

# Explanation

```
FVcVv2l@_@L

F           In range 1 to the input, do this ...
 Vv         Vowels
   Vc       Consonants
     2l     Wrap the two inside a list
       @    Index the constructed list into the counter
            Note that the counter starts at 1,
            so this picks the constants list
            before the vowels list.
        _@  Index by the current counter
            (Stax doesn't have random number support)
          L Wrap the whole stack into a list

```

# Answer
> 2 votes
# GolfScript, 36 bytes

```
,{['aeiou'.123,97>^]\2%=.,rand=}%''+

```

Try it online!

# Answer
> 2 votes
# Ruby, 76 bytes

Basic recursive function that adds a consonant and a vowel each time until there's only one character left, at which point it adds just the consonant.

```
f=->n{[*?b..?z].grep(/[^eiou]/).sample+(n<2?'':'aeiou'.chars.sample+f[n-2])}

```

Try it online!

# Answer
> 2 votes
# Python, 83 bytes

```
lambda n:[*map(choice,["bcdfghjklmnpqrstvwxzy","aeiou"]*n)][:n]
from random import*

```

Attempt This Online!

Outputs a list of characters.

This is conceptually the same as grc's answer for "Generate a pronounceable word", since the questions are almost identical.

# Answer
> 2 votes
# Vyxal `s`, 9 bytes

```
⟑₂¨ikvk¹℅

```

Try it online!

Explanation:

```
⟑          # Map over the range 1 to n
 ₂¨i       # If even:
    kv     #   Push the string "aeiou"
           # Otherwise:
      k¹   #   Push the lowercase consonants
        ℅  # Get a random character from the top of the stack
           # Concatenate the character list into a string with the s flag

```

# Answer
> 2 votes
# Pip, 12 bytes

```
RC*[.CZVW]Ha

```

Try It Online!

### Explanation

This should be 11 bytes; the `.` is a no-op to work around a bug in the current language version.

```
RC*[CZVW]Ha
   [    ]    List containing:
    CZ         Lowercase consonants
      VW       Lowercase vowels
          a  Command-line argument
         H   Take that many elements (cycling the list as necessary)
RC*          Random choice from each

```

---

I also found several 13-byte solutions:

```
RC{VW::CZ}M,a
RC[CZVW]@_M,a
LaORC(VW::CZ)

```

# Answer
> 2 votes
# Bash, <sup>93</sup> 89 bytes

```
v=aeiou]
until tr -dc a-z</dev/urandom|head -c$1|grep -E "^[^$v([$v[^$v)*[$v?$";do
:
done

```

Try it online!

A full command line program.

It generates random lowercase alpha strings of the required size in a loop until we find one matching the pattern `^<vowel>(<cons><vowel>)*<cons>?`.

# Answer
> 2 votes
## , 124 bytes

```
auto f(int n){string s;for(import std;n;n--,s~=n%2?"aeiou"[uniform(0,5)]:"bcdfghjklmnpqrstvwxyz"[uniform(0,20)]){}return s;}

```

I'm not very good at code golf (but trying to get better) so this can probably be improved a lot

Try it online

# Answer
> 2 votes
# Vyxal `rṀs`, 8 bytes

```
ƛkvk⁰"i℅

```

Try it Online!

Fun

# Answer
> 1 votes
# Factor \+ `pair-rocket sequences.repeating`, 62 bytes

```
[ "bcdfghjklmnpqrstvwxyz"=> "aeiou"swap cycle [ random ] map ]

```

Attempt This Online!

```
                                   ! 5
"bcdfghjklmnpqrstvwxyz"=> "aeiou"  ! 5 { "bcdfghjklmnpqrstvwxyz" "aeiou" }
swap                               ! { "bcdfghjklmnpqrstvwxyz" "aeiou" } 5
cycle                              ! { "bcdfghjklmnpqrstvwxyz" "aeiou" "bcdfghjklmnpqrstvwxyz" "aeiou" "bcdfghjklmnpqrstvwxyz" }
[ random ] map                     ! "furom"

```

# Answer
> 1 votes
# Pyth, 19 bytes

```
J"aeiou"smO?%d2J-GJ

```

Test suite

##### Explanation:

```
J"aeiou"smO?%d2J-GJ  | Full code
J"aeiou"smO?%d2J-GJQ | with implicit variables
---------------------+--------------------------------------------------------
J"aeiou"             | J = "aeiou"
         m         Q | For each d in [0...input):
          O          |  Pick a random letter from
               J     |   J
           ?%d2      |   if d is even else
                -GJ  |    the lowercase alphabet minus J (i.e. the consonants)
        s            | Print the concatenated results

```

# Answer
> 1 votes
# C (gcc), ~~61~~ 58 bytes

```
c;f(n){for(;n;4370%c-n&1&&putchar(c,n--))c=97+clock()%26;}

```

Try it online!

-3 bytes thanks to ceilingcat!!

# Answer
> 1 votes
# Raku, 67 bytes

```
{$!=;({(('a'..'z')∖$!,$!)[$++%2].pick}...*)[^$_].join}

```

Try it online!

* The vowels are stored in `$!`, one of just two special global variables that don't need to be declared.
* `{ ... } ... *` is a lazy, infinite list, where the code between the braces generates each successive element.
* `('a' .. 'z') ∖ $!` are the consonants. That  isn't a backslash, it's the Unicode `SET MINUS` character.
* `(('a' .. 'z') ∖ $!, $!)[$++ % 2]` alternately chooses the consonants and vowels on each iteration of the generator. The anonymous state variable `$` counts how many iterations there have been so far, and the `% 2` reduces that to the alternating sequence `0, 1, 0, 1, ...`.
* `.pick` chooses a random vowel or consonant.
* `[^$_]` takes a number of elements from the sequence equal to the argument passed to the function.
* `.join` joins those elements into a single string.

# Answer
> 1 votes
# Zsh `--braceccl`, 67 bytes

Try it Online!

```
shuf -n$1 <(echo {bcdfghj-np-tv-z}{aeiou}|rs 0 1)|rs -g0|cut -c -$1

```

Similar to the pronounceable word solution.

# Answer
> 1 votes
# Japt `-mP`, 12 bytes

```
;Ck%+Ugciv¹ö

```

Try it

```
;Ck%+Ugciv¹ö     :Implicit map of each U in the range [0,input)
;C               :Lowercase alphabet
  k              :Remove
   %+            :  Append to "%"
     Ug          :  Index U into
       civ       :    "c" prepended with "v"
          ¹      :End remove ("%v"=/[aeiou]/gi "%c"=/[b-df-hj-np-tv-z]/gi)
           ö     :Random character
                 :Implicitly join & output

```

# Answer
> 1 votes
# Nim, 148 bytes

```
import random
randomize()
proc x(y:int):string=
  let l="bcdfghjklmpqrstvwxyz";let a="auioe";for i in 0..y-1:result.add sample(if(i%%2)==0:l else:a)

```

Attempt This Online!

---
Tags: code-golf, random
---


title: No strings attached!

text:
# Question
Title: No strings attached!
### Intro

There are 3 nails in the wall. You've got a piece of string that is fixed to the picture frame with both ends. To hang the picture, you entangled the string with the nails. But before letting the picture go: Can you predict whether the image is going to fall, just by looking at how the string is wrapped around the nails?

In the first example the picture will not fall. In the second example the picture is going to fall.

### Challenge

Given the path of the string around `N` nails, determine whether the picture is going to fall or not. Return a truthy value if the picture is going to fall, and a falsy value otherwise.

### Details

* You can assume that the nails and the picture are arranged in a regular `N+1`-gon, with the picture at the bottom.
* You can assume that there are no knots in the rope, i.e. the rope can be continuously be uwrapped from one of the two ends.
* Each nail is enumerated clockwise with a letter of the alphabet. You can assume that there are at most 26 nails (A-Z).
* A clockwise wrap around a nail is denoted with the lower case letter, a counter clockwise wrap is denoted with an upper case letter.

The first example from above will be encoded as `BcA`, the second example is encoded as `CAbBac`.

For the inclined reader: This problem is equivalent to determining whether an element of the free group \- generated by the set of nails - is the identity or not. This means it is sufficient to repeatedly cancel substrings like `aA` or `Aa` until you reached a fixed point. If the fixed point is an empty string, this is the neutral element, otherwise it is not.

### Examples

```
Picture will fall:
Aa
CAbBac
aBbA
DAacAaCdCaAcBCBbcaAb
ARrQqRrUuVHhvTtYyDdYyEKRrkeUWwua
AKkQqEeVvBESWwseYQqyXBbxVvPpWwTtKkVHLlWwNBbAanYYyyhWwEJZUuNnzjYyBLQqQqlEGgebeEPLlTtZzpUuevZzSsbXSGgsUuLlHhUQquPpHUuFfhTZzIitGgFAaBRrBbbYXxOoDZTDdtzVvXxUudHhOVvoUuXKkxyBEeLlbFfKkHhfVAaQqHAaJjODdoVvhSsZzMZzmPpXNBbnxBbUuSSsUuDRrdNnUusJDIiUuIidCEGgeMmcLlDPOopdTEeQqCAETtNnYyeGUuPEFfSsWwHheAaBbpgCcOHUuhAaCcoEFBbfeaFHhfcCFFffNncGFfgtjMVUuKAakvKkXxLlTMmtmOFfoUuXSsYZzLXxlyxUuRPZzTtprSsWwRrPLlpGgMmKRrDHhdRCcUurYNnKCckykXJjxWwUSsJjKkLlKkuBbBbOoWwWwIiUuPDdBbCcWHBbCFfcDdYBbLlyVvSsWGgEewCchDdYywAaJjEepPpPpQXxZzFfLGXxglNnZzYDdyqCcKWXxwXxQqXTtxkFfBSSAasTFftZzsXGgxSsLlLlbZzAaCCccXVvYyxTIiOoBbFftCVQqDdBbGgAavQqKkDPpKTCctRrkdcvAaQWOowLOolqVMmvZAaHCBbcPphIiRKkrLlzFMOomDIiXJjIixMmdNnMHhmfNTtIiKkSDdTtsVvHhnAaNSVvTUutNnXxsGIiXxPpPHhUupgNnAaAAOoaaIiHJjhVvLlnYyXxQqSsTtKJjkBbNnVvEYCcFfMHGghBbmNnEeJTtjJjWYywyeNWwDIiZYyzOodnMQqmVvCcQqxVvGNnEeNBbngVvUGgYyBbDdVvIiAAaauPpQKDdEekNnVLlvHhGSDIidPZzpsPCcpgQqKkQqNOonLlIiLlJjqPAaPXxTtppYyCPpHhCIicARBbracXxWwXEVUuUuGgZHhzBSsbvGgFfeVvxLlNKknWwBLlIibWOowNnRSsrSEeKAakOosLZzZRrHhzTtTFfUuNnOKkotXxTtla

Picture will not fall:
A
BcA
ABCD
aBaA
bAaBcbBCBcAaCdCaAcaCAD
ARrQqRrUatuVHhvTYyDdYyEKRrkeUAua
AEEeQqNneHhLlAIiGgaECXxcJjZzeJFfVWwDdKkvYWwyTJjtCXxANIinaXWwxcTWwtUuWwMmTBbVWIiFLlWwZzfwPLlEepvWZzwKkEYEeWXxwySXTtEexRIiNBbnWAaTtQqNnBMSsWwOombwWwPVPpGPpgYyvDdpBbrQqHhUusKRrDAVvadLlWwOZzokGJCXSSssXxxJPpGIigZzjJjLlOoNRrnPpcMZzmjgJjNDEeQqWKkNTtnSswIidCcnYBGgbyJSsjPpIiMmMmMmSNnWVvwZzIQqLXHhxTPptlisOoeTtTtYMmVvPpyKNnMFfmkXxSVvsCGJjXxgXYJPpjWwQIiXxqyDdxFfDdAaRNnJjrctHBbZzhEQqMmeCcRBbrGgAaAaJNnRrYyWwSDdVvsJOojQGgWWwIBbiwRrqJjjWwOoFPMmDdRrQOoqNnRrDPJjpMmdPpGFfVvWUuwgpWCcNnPpwfUXCcZzJjUSsuXxxUuuRGgHhrSQqJjOosMMTtmHhmKkXxDdLlWwjSUuAaMmKYyksZzVvPZzVEeVvvHhZZOozBbzMmZCczYyGgISsiQqpXxMmXxEMmeRrAGgaGgMOGgomZFfDdzSSssBGPpgbTtBbOoRWWwGgLJjlEeGgLDdRrUulNnZzJjJjUKkuXxFfwATtaZzLVvlWwSsMmrBAaELleGBLFflbgHhbIFfiBbPpTWZzwKkKLASsaTJYyjtBbBbWwIiZCcWwzIiZLlUTtuBbYyBbIizTJjtLTtDOOoBbodBbllSsUGgLlAKkauYykUuUNnPpuDFfAaLNVvnVvlHhdMmBAaBbIiVRrGWOoPpwgWXwKkvJjOoTtYCUucVGgYyLlVvFfvRrMmySsDdbtICZzcNnINSOosDQAaXoxRGgKkrqdZznDdXxZzMGgmiJjNnACcMQqmaNnWZzUOuwTVvAJjSsaRrGgSsTtOMmRroVvRrtAVGgvMmaINniDGCcOogRrWwMVvYFfyTtmTtVvOoOIiodRrGgAxaSsGgiJja

```

# Answer
## Retina, 21 bytes

```
+`(.)(?!\1)(?i)\1

^$

```

Try it online!

Like flawr's solution, this just repeatedly deletes adjacent uppercase/lowercase pairs and then checks whether the result is empty or not.

As for how one matches an uppercase/lowercase pair:

```
(.)     # Match and capture a letter.
(?!\1)  # Ensure that the next character is not the same, to avoid matching
        # "aa" and "AA".
(?i)    # Turn on case-insensitivity.
\1      # Match the backreference. In .NET, when using case insensitivity,
        # backreferences also get case-insensitive, so this *can* still match
        # iff the cases of the two letters are different.

```
> 11 votes

# Answer
# MATLAB, 76 bytes ~~Octave, ~~82~~ ~~79~~ 77 bytes~~

This might be the first time I've seen where MATLAB is actually *shorter* than Octave (by an entire byte)!

New answer in MATLAB:

```
c=input('');k='Aa';while k<1e5,k=k+1;c=strrep(c,65+mod(k,64),'');end;~nnz(c)

```

Answer in Octave:

```
c=input('');k='Aa';while k++<1e5,c=strrep(c,['',65+mod(k,64)],'');end;~nnz(c)

```

Saved ~~three~~ five bytes thanks to flawr. `~nnz(c)` is shorter than `isempty(c)`, and `'Aa'` is two bytes shorter than `[0,32]`.

Try it the Octave-version online!

---

**Explanation:**

`c=input('')` asks the user for input. We define `k='Aa'` as a character array.

`while k++<1e5`: While loop where both elements in `k` are incremented each iteration, `Aa`, `Bb`, `Cc` and so on. The loop will continue until the largest element is `1e5`, which should be sufficiently high for most strings. It can be increased to `9e9` without increasing the byte count.

We'll take the `strrep` function in steps, starting from the middle.

By using `mod(k,64)` we'll get the following when we reach the end of the alphabet (if we convert `k` back to characters):

```
ans = Yy
ans = Zz
ans = [{
ans = \|
ans = ]}
ans = ^~
ans = _
ans = `�
ans = aA
ans = bB

```

As you can see, there will be some symbols in between, but then it will wrap around and start with the alphabet again, but now with the lower case letters first. This is a very short way to check both `Aa` and `aA`.

`['',65+mod(k,64)]` concatenates the numeric values from the `mod`-call, with an empty string, converting the numbers to characters.

`strrep` is used to remove elements from the string `c` and return it. It will search for all occurrences of `k` in the string and replace it with an empty string.

After `1e5` iterations we'll either have an empty string or a non-empty string. We check if there are any elements in `c` using `nnz(c)`. We return `not(nnz(c))`, thus `1` if it's empty, and `0` if there are characters left in `c`
> 7 votes

# Answer
## Minkolang 0.15, 30 bytes

```
od4&x,N.I1=$6&d3~c-$~48*=,2&xx

```

Try it here!

### Explanation

```
od                            Take character from input and duplicate it
  4&                          If top of stack is truthy, jump 4 spaces
    x                         Dump top of stack
     ,                        NOT top of stack
      N.                      Output as number and stop

    I1=                       1 if stack has 1 element, 0 otherwise
       $6&                    If top of stack is truthy, jump 16 spaces (to the beginning)
          d3~c                Duplicate top two items of stack, in reversed order
              -               Subtract
               $~             Absolute value
                 48*          Push 32
                    =,        0 if top two items are equal, 1 otherwise
                      2&xx    If top of stack is truthy, dump two elements from top

```

Minkolang's toroidal nature is leveraged here to eliminate the need for an outer loop. The general idea here is to check if the top two elements of the stack are 32 units apart (meaning they're an uppercase/lowercase pair), and if they are, pop both of them off. Since this is done "in realtime", so to speak, nesting of pairs is handled properly.
> 6 votes

# Answer
# Haskell, ~~98 97 85~~ 81 bytes

This is just a naive implementation that repeatedly tries to cancel adjecent letters until there is no more change, and then determines the result from that.

Thanks @nimi for -12 bytes and @xnor for another -4 bytes!

```
o=fromEnum
r(a:b:l)|abs(o a-o b)==32=l|1>0=a:r(b:l)
r x=x
f=null.until((==)=<<r)r

```

Try it online! or Verify all examples!
> 5 votes

# Answer
## Haskell, 62 bytes

```
a%l|b:t<-l,abs(a-b)==32=t|1>0=a:l
f=null.foldr((%).fromEnum)[]

```

Try it online

Credit to flawr for the `abs` and Laikoni for the `fromEnum` map.

The helper function `%` takes an already-simplified string `l`, and prepends the symbol `a` before simplifying the result. If `l` starts with the inverse character to `a`, they cancel. Otherwise, `a` is simply prepended. Note that no further simplification is needed at this stage.

The main function `f` prepends and simplifies each character in turn via a `foldr`. Then, it checks whether the result is empty.

To check whether two characters are opposite cases and so should cancel, see if their ASCII values differ by 32. Each element is processed by `fromEnum` before being passed to `%`.
> 5 votes

# Answer
# 05AB1E, 17 bytes

```
DvADu‚øDíìvyK}}õQ

```

Try it online!

**Explanation**

```
Dv                 # input number of times do:
  A                # push lowercase alphabet
   Du              # push uppercase alphabet
     ‚ø            # zip the alphabets together (['aA', ..., 'zZ'])
       Díì         # prepend a copy with each element reversed ('Aa' ...)
          v        # for each pair in the resulting list
           yK      # remove it from the accumulated string (starts as input)
             }}    # end loops
               õQ  # check result for equality to empty string

```
> 4 votes

# Answer
# Mathematica, 102 bytes

```
""==StringDelete[""|##&@@#<>#2&~MapThread~{Join[a=Alphabet[],A=ToUpperCase@a],A~Join~a}]~FixedPoint~#&

```

Unnamed function taking an alphabetic string as input and returning `True` or `False`.

The heart of the implementation is creating a function that deletes any cancelling pair, like `"Pp"` or `"gG"`, from a string. The expression `{Join[a=Alphabet[],A=ToUpperCase@a],A~Join~a}` produces an ordered pair of lists of characters, the first list being `{"a","b",...,"Z"}` and the second being `{"A","B",...,"z"}`. Then `#<>#2&~MapThread~` produces a list where the corresponding elements of these two lists have been concatenated, that is, `{"aA","bB",...,"Zz"}`. The fun expression `""|##&@@` then (through the magic of the argument sequence `##`) produces a list of alternatives `"" | "aA" | "bB" | ... | "Zz"`; finally, `StringDelete[...]` is a function that deletes any occurrence of any of those alternatives from a string.

It now suffices to repeatedly apply that function to the input string until the result doesn't change, which is accomplished by `~FixedPoint~#`, and then test whether the result is the empty string with `""==`.
> 3 votes

# Answer
## JavaScript (ES6), 73 bytes

```
f=(s,t=s.replace(/(.)\1+/gi,s=>s.replace(/(.)(?!\1)./,'')))=>s==t?!s:f(t)

```

Unlike .NET, JavaScript has no way of turning off case sensitivity in the middle of a match, so instead we have to find all substrings of repeated letters case insensitively, and then delete any mismatching pair of adjacent characters, which by this point must be an upper/lowercase pair.
> 3 votes

# Answer
## Perl, 28 bytes

```
1 while s/.(??{$&^' '})//;$_

```

**Explanation:**

Perl allows one to include a dynamically generated regular expression inside of a standard regular expression.

The `.` matches anything.

The `(??{` is the start of the generated regex.

The `$&` variable will contain the entire matched string so far, which in this case is just whatever `.` matched.

The `^` operator does either numeric xor or string xor, depending on the values of the operands. In this case, it will be string xor.

The `' '` is just a string containing a space, which conveniently has the ascii (or unicode!) value of 32. When a space is xor-ed with a char in the range a-z or A-Z, it will change from upper to lower case or vise versa.

The `})` is the end of the generated regex.

`1 while s/whatever//` will repeatedly search for a pattern and replace it with the empty string.

`$_` is the default variable. This variable is what perl does fun and exciting stuff upon when you don't specify another variable. Here I'm using it to return a truthy or falsy value, since a zero length string is false, and a nonzero length string which does not equal `"0"` is true. I'm also assuming that the input string was originally placed in it.

Try it here
> 3 votes

# Answer
# Prolog (SWI), 151 bytes

```
f(S):-S="";string_code(I,S,X),string_code(J,S,Y),J is I+1,32is abs(X-Y),B is J+1,sub_string(S,0,I,_,T),sub_string(S,B,_,0,U),string_concat(T,U,V),f(V).

```

Takes a long time to run on the longer false cases because of backtracking.

Try it online!

**Ungolfed**

```
f(S):-                       The string S corresponds to a falling picture if:
  S="";                      S is the empty string, or...
  string_code(I,S,X),        X is the character code at some index I
  string_code(J,S,Y),        Y is the character code at some index J
  J is I+1,                  J is I+1
  32 is abs(X-Y),            X and Y differ by 32 (difference between lower/upper case)
  B is J+1,                  ...
  sub_string(S,0,I,_,T),     ...
  sub_string(S,B,_,0,U),     ...
  string_concat(T,U,V),      ...
  f(V).                      The concatenation of the substrings before and after
                             the letters X and Y corresponds to a falling picture.

```
> 2 votes

# Answer
# JavaScript (Node.js), 55 bytes

```
x=>Buffer(x).map(c=>c==e[i]?--i:e[++i]=c^32,i=e=[])&&!i

```

Try it online!
> 2 votes

# Answer
# MATL, 20 bytes

```
t"[]yd|32=fX<tQh(]n~

```

Try it online! Or verify all test cases (it takes a while).

### Explanation

```
t       % Input string implicitly. Duplicate
"       % Do as many times as input size
  []    %   Push empty array
  y     %   Duplicate current string onto the top
  d|    %   Absolute consecutive differences
  32=   %   Convert to true if 32, false otherwise
  fX<   %   Index of first occurrence of true, or empty of all false
  tQ    %   Duplicate, add 1. This gives the next index, or empty
  h     %   Concatenate. Gives the two consecutive indices of letters
        %   to be removed, or empty
  (     %   Assign an empty array to those positions, i.e. delete them
]       % End
n~      % Number of elements, negate

```
> 1 votes

# Answer
# Wolfram Language (Mathematica), 58 bytes

```
(Or@@ToCharacterCode@#//.y_||z_/;Abs[y-z]==32:>1<0)===1<0&

```

Try it online!
> 1 votes

# Answer
# C `-m32`, 100 + 4 = 104 bytes

```
n;i,k;j;f(s){for(i=0;~++i;)if(k=i%128,n=(k^32)<<8|k,(j=strstr(s,&n))&&k)memmove(j,j+2,strlen(j+1));}

```

No TIO link, because it takes a few minutes to execute, as it loops through all 32-bit integers.

It takes a `char *` (zero-terminated string) which will be modified and points to `\0` iff the result is empty.

We construct an string containing an uppercase and a lowercase letter with `(k^32)<<8|k`. When this int is read as a little-endian `char *`, the top 2 bytes are the null terminator. If that substring is found, we delete these 2 characters with `memmove`.
> 1 votes

# Answer
# Jelly, 15 bytes

```
ØẠżŒs¤œṣF¥ƒ$ÐLṆ

```

Try it online!

Outputs `1` if the picture will fall, and `0` if not

## How it works

```
ØẠżŒs¤œṣF¥ƒ$ÐLṆ - Main link. Takes a string S on the left
           $    - Group the previous 2 links into a monad f(S):
     ¤          -   Group previous links into a nilad, A:
ØẠ              -     Alphabet; "ABC...XYZabc...xyz"
   Œs           -     Swapcase; "abc...xyzABC...XYZ"
  ż             -     Zip; ["Aa", "Bb", ..., "Yy", "Zz", "aA", "bB", ..., "yY", "zZ"]
         ¥      -   Group previous 2 links into a dyad g(S, p), where p is some pair of letters:
      œṣ        -     Split S at this pair
        F       -     Flatten
          ƒ     -   Reduce the nilad A by g(S, p), initialising with S on the left
            ÐL  - Repeatedly apply f(S) until a fixed point (empty list if fall, non-empty if not)
              Ṇ - Logical NOT

```
> 1 votes

# Answer
# Python 3, 71 bytes

```
s=input()
for i in s*len(s):s=s.replace(i+i.swapcase(),'')
print(not s)

```

Try it online!
> 0 votes

---
Tags: code-golf, string, decision-problem, abstract-algebra, knot-theory
---