Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

You are to print this exact text:

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


Specs

• You may have extra trailing newlines.
• You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is . Shortest answer in bytes wins.

• @DylanMeeus "You are to print this exact text:" Aug 4, 2016 at 12:56
• @DylanMeeus Since that is to do with the dev tools hiding repeated console outputs, and isn't native to JavaScript consoles as a whole and is not in the JavaScript spec - as well as the fact that feature can be turned off - i think it should be acceptable. Not all browsers will collapse it like that. Aug 4, 2016 at 12:58
• One of the most interesting things about this challange is that depending on your language ********** can be shorter then a loop. Makes me wonder when it's better for a given language to switch between 1 or 2 loops. Aug 5, 2016 at 9:14
• you say trailing new lines are acceptable. Are leading newlines acceptable too? Feb 10, 2017 at 2:34

q/kdb+, 19 13 bytes

Solution:

-1(2#10)#"*";


Example:

q)-1(2#10)#"*";
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********


Explanation:

-1(2#10)#"*"; / solution
"*"  / the asterisk
#     / take or reshape
(2#10)      / list (10;10), 10 rows, 10 columns
-1           ; / print to stdout


Pyth, 6 bytes

Bet there's going to be a shorter Charcoal answer

VT*T"*


Explanation:

VT     Ten times
*T"*  Output ten asterisks followed by a newline


Try it online!

• ---nope :|--- yep Sep 7, 2017 at 1:55
• @ASCII-only why am i alive Sep 7, 2017 at 2:11

Java 8, 73 62 bytes

o is a String passed to a Consumer

o->System.out.print("**********".replace("*", "**********\n"))

• o->System.out.print("**********".replace("*", "**********\n")) Sep 28, 2017 at 14:19

R: 33 bytes

write.matrix(matrix("*",10,10))


This does assume that you've loaded the MASS library.

Powershell, 78 bytes

$h=@();$v=@();1..10|% $_{$h+="*"};$i=0;Do{$v+=$h-join'';$i++}while($i-ne10);$v


Code explode:

$numbers = 1..10$horArray = @()
$verArray = @() Foreach ($number in $numbers){$horArray += "*"
}

$i = 0 Do {$verArray += $horArray -join ''$i++
}
while ($i -ne 10)$verArray


Symbolic Python, 41 bytes

_=-~(_==_)
_=_**-~_+_
_=("*"*_+"""
""")*_


Try it online!

Explanation

• _=-~(_==_) sets the value of _ to True, which is interchangeable with 1
• _=_**-~_+_ performs 2**3+2, resulting in 10, and stores this in _
• "*"*_ constructs a row, and +"""\n""" appends a newline.
• This is multiplied by _, 10, to create the square.
• At the end of execution, the value left in _ is printed.

Befunge, 33 bytes

55+:v
_v#:<,"*"-1
^_1-:!#@_55+:,1


Try It Online

How it works

55+:v
....<... Initialises the stack with two 10s as counters.
........ The first is for the outer loop, and the second is the inner

.....
_v#:<... Checks whether the inner counter is 0
._......

.....           If so, decrement the outer counter
_..........       If the outer counter is 0, exit the program
^_1-:!#@_55+:,1   Else print a newline and reset the outer loop counter

.....
.....,"*"-1 Else, decrement the inner counter and print an *
........... And run the inner loop again


Befunge-98, 19 15 bytes

a1_@#:-,ka:k8*'


Try It Online

First time using 98 instead of 93. Both the k and ' commands are immensely useful.

Kotlin, 41 bytes

Submission

fun f()=(0..9).map{println("**********")}


Test

fun f()=(0..9).map{println("**********")}

fun main(args: Array<String>) {
f()
}


TryItOnline

• I believe lambda body is enough - 33 bytes Jul 2, 2018 at 8:38

Thue, 30 bytes

%::=~**********
::=
%%%%%%%%%%


Try it online!

Thue, 53 bytes

%::=,*,*
>*::=>[
>,::=>]]
[::=~
]::=~*****
::=
>%%%%%


Uses the convention that "when a string is sent to the output stream, no newline is printed at the end, except if the string is empty, in which case a newline is all that is printed." This is not followed by the TIO interpreter.

Io, 32 bytes

10repeat("*"repeated(10)println)


Try it online!

Julia, 23 bytes

print(("*"^10*"\n")^10)


Explanation:

print(                ) # Print
(           )     # A string consisting of
"*"^10           # "*" duplicated 10 times
*"\n"      # then concatenated to a newline
^10  # which is then duplicated 10 times


Canvas, 5 bytes

*Ａ×Ａ＊


Try it online!

With notes (not valid code, as Canvas does not support comments):

          Print the following (implicit)
*         The string "*"
Ａ×      Duplicated 10 times horizontally
Ａ＊  Duplicated 10 times vertically


Japt-R, 5 bytes

AÆAç*


Try it online!

Unpacked & How it works

Ao@Aç*

Ao@    Map range(10) with a function that returns...
Aç*      "*" repeated 10 times.
-R flag joins the result array with "\n"
Implicit output


Japt-R, 5 bytes

AÆAî*


Test it

Tcl, 25 bytes

time {puts **********} 10


Try it online!

Python 2, 20 bytes

print("*"*10+"\n")*10


I didn't know you could remove the space between print and the string.

Q'Nial7, 15 bytes

10 10reshape'*'               #create atom '*', reshape to 10 by 10 matrix


putStr$[0..9]>>([0..9]>>"*")++"\n"  λ> putStr$[0..9]>>([0..9]>>"*")++"\n"
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********

• Since the question stipulates you have to print the text your likely need a main=. I'd also point out that "*********\n" is shorter than ([0..9]>>"*")++"\n". Jul 2, 2018 at 0:21
• @CatWizard No need for main. Your proposal is already taken. Jul 2, 2018 at 0:24
• @CatWizard I am running GHCi on my terminal. Isn't that allowed? Jul 2, 2018 at 0:39
• GHCi is allowed. It is generally considered a different language from Haskell. If other people are not using main and no one has done anything I think you will fine though. Jul 2, 2018 at 0:42
• @CatWizard I added a demo so that readers know this is to be used in an interpreter. Jul 2, 2018 at 0:46

Z80Golf, 14 bytes

00000000: 0a4f 3e2a 46ff 10fd 7eff 0d20 f576       .O>*F...~.. .v


Try it online!

Disassembly

start:
ld a, (bc)  ; 0a
ld c, a     ; 4f
loop1:
ld a, '*'   ; 3e 2a
ld b, (hl)  ; 46
loop2:
rst $38 ; ff djnz loop2 ; 10 fd ld a, (hl) ; 7e rst$38     ; ff
dec c       ; 0d
jr nz, loop1  ; 20 f5
halt        ; 76


Golfing nested loops

Since a is the parameter to putchar, I used b and c for loop counters. The loop constructs are

  ld b, ... ; 1 or 2 bytes
loop:
(loop content)
djnz loop ; 2 bytes


and

  ld c, ... ; 1 or 2 bytes
loop:
(loop content)
dec c     ; 1 bytes
jr nz, loop ; 2 bytes


This combination of 2-level nested loops is optimal in Z80Golf.

Reusing the first instruction as data

The first byte 0a is located at memory address $0000. Since hl is always zero in this program, we can use the one-byte instruction ld r, (hl) whenever we need the constant 0a, instead of the two-byte ld r,$0a.

In this particular challenge, the byte $0a has three uses: the outer loop, the inner loop, and the newline character. The byte as an instruction is not particularly useful, so we save two bytes here. Matlab, 17 bytes @()repmat('*',10)  Try it Online ORK, 185 bytes When this program starts: I have a scribe called W W is to write "**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********"  Try it online! ORK does everything (even I/O and basic math) with objects. As far as this question goes, looping does not have to be one of them. q, 12 bytes 10 10#get"*" / a 10x10 matrix  • 10 10#(*) should have the same effect. But I'm not sure if spaces are allowed between asterisks. – ngn Sep 28, 2018 at 1:24 MBASIC, 32 bytes 1 WIDTH 10:PRINT STRING$(100,42)

RUN
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********


No loop. Just printing 100 asterisks into a 10 character wide terminal to force line wraps.

There's no MBASIC on TIO, so I've linked the reference manual.

Premier, 8 bytes

'*U*N+U*


Try it online!

The boring way.

Explanation

'*U*N+U*     full program
'*           push "*"
U          push 10
*         repeat
N+       append newline
U      push 10
*     repeat


Premier, 14 bytes

QnN
**********


Try it online! This second approach uses Premier's implicit data iteration. It iterates over each character in the data (the second line), and executes the program (the first line) for each character. The data QnN pushes the data (Q), outputs it (n), then pushes a newline (N), to be implicitly outputted. This iterates 10 times, printing a 10x10 grid of asterisks.

Excel VBA, 11 Bytes

Anonymous VBE immediate window function that outputs a 10x10 grid of * to the ActiveSheet object

[A1:J10]="*


Perl 5, 66 bytes

$x = 1x10;$x =~ s/\d/*/g;for($i = 1;$i <=10; $i++){print "$x\n";}


Try it online!

• You can remove literally all the whitespace
– Jo King
Feb 19, 2019 at 23:59

MathGolf, 7 bytes

♂⌂*n+♂*


Explanation

♂⌂*     Push asterisk multiplied by 10("**********")
n    Append a newline
+   Concatenate the two strings
♂* Multiply the string by 10
implicit output


Try it online!

Python 3, 23 bytes

print(10*(10*"*"+"\n"))


Try it online!

In this case, the obvious answer is best. I tried some other ways, but all were equal or longer in length.

23 bytes (alternative)

print(10*f"{10*'*'}\n")


24 bytes

print(10*"**********\n")


25 bytes

exec(10*"print(10*'*');")


29 bytes

print("\n".join(10*[10*"*"]))


32 bytes

for _ in range(10):print(10*"*")


43 bytes

print(*(10*"*"for _ in range(10)),sep="\n")


PHP, 26 bytes

Just used a compressed string. Has raw output of gzdeflate and contains unprintable binary data, so the code itself and direct TIO link cannot be posted here, but here is a hex dump of it:

000000  3c 3f 3d 67 7a 69 6e 66 6c 61 74 65 28 22 d3 d2  <?=gzinflate("..
000010  82 01 2e 2d 9a 33 01 22 29 3b                    ...-.3.");


Save it as a binary file then execute it like this: php asterisks.php

TIO which uses bash to run this file: Try it online!