# 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
• @LeakyNun Leaderboard snippet please! Aug 4, 2016 at 22:08
• 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

## Check, 15 bytes

"*">10:r*R]+R*o


Pushes the string * and repeats it ten times, while also storing 10 in the register. Then adds 10 to the end of the string (a newline), then repeats the whole thing 10 times.

# Bound, 13 12 bytes

10:c42:d*@RS


Thanks to Razetime for the -1 byte
Explanation:

1 # Put 1 onto the stack [1]
0 # Put 0 onto the stack [1, 0]
: # Combine the top two elements [10]
c # Copies the top element [10, 10]
4 # Put 4 onto the stack [10, 10, 4]
2 # Put 2 onto the stack [10, 10, 4, 2]
: # Combine the top two elements [10, 10, 42]
d # Convert the top element into a char [10, 10, '*']
* # Multiply the top two elements [10, '**********']
@ # Sorts the stack ['**********', 10]
R # Repeat the next command n times, where n is top element (10) ['**********']
S # Print the top char/string (creates newlines)


Try it online!

• Welcome to the site and nice first answer! Oct 14, 2020 at 15:51
• 12 bytes: 10:c42:d*@RS Oct 14, 2020 at 16:03
• @cairdcoinheringaahing thank you! excited to be here Oct 14, 2020 at 16:13
• @Razetime nice! Oct 14, 2020 at 16:14

# Brian & Chuck, 23 bytes

*{-?
{..........>-.+?


Try it online!

The   is the ascii code 11.

Brian:
*      "*" 11
{-    Restart Chuck's code and subtract 1
?   Go to Chuck's code while the first byte is not 0

Chuck:
11 (This will be decremented by 1 each line)
{                  Restart Brian's code
..........        Print the "*" 10 times
>-.+    Print the newline
?   Go back to Brian's code


# Python 3, 67 bytes

print('\n'.join(''.join('*' for x in range(10))for y in range(10)))


Try it online!

• Welcome to the site, and nice first answer! Dec 1, 2020 at 20:10
• 62 bytes by saving range(10) as a variable and removing the space after '*' Dec 1, 2020 at 21:42
• Don't forget to check out existing Python solutions to this problem. The current record is 20 bytes (Python 2) / 22 bytes (Python 3). Dec 1, 2020 at 23:24

# Zsh-F, 19 bytes

yes **********|head


Try it online!

Edit: just saw this exact answer was already posted for bash :(

• alt approach (22 bytes): jot -b'**********' 10 Mar 15, 2021 at 1:55

# Java 11, 48 chars

for(int i=0;i++<10;out.println("*".repeat(10)));


Try it online!

# Java 5, 53 chars

Static imports

for(int i=0;i++<100;out.print("*"+(i%10>0?"":"\n")));


Try it online!

# Java 3, 60 chars

Plain old Java

for(int i=0;i++<100;System.out.print("*"+(i%10>0?"":"\n")));


Try it online!

# C (gcc), 41 bytes

main(n){++n<puts("**********")&&main(n);}


Try it online!

Or if you don't have any problem using a function that would work only the first time it's called (because to make it work again you should reset the value of n)

# C (gcc), 38 bytes

n=9;f(){puts("**********");n&&f(--n);}


Try it online!

And a 38 bytes dupe

n;f(){++n+1<puts("**********")&&f(n);}


Try it online!

Note that even the first code works only one time, it doesn't reset anything, you need to run the program again to have another 10x10 grid. However for some (questionable) reason they allow printing the grid just once per program run when using main, but not when using another function.

• This prints a 10*n grid of asterisks. Taking extra input (the 10 in this case) is not allowed Jan 19, 2021 at 3:51
• @ppery fixed it, thank you so much Jan 19, 2021 at 4:30
• Nope, your answer is now a non-reusable function, so still not allowed. Jan 19, 2021 at 4:42
• Omg I am learning a lot from you! I will fix even this one Jan 19, 2021 at 5:01
• @ppery resetting the global variable at the end of the function requires too much unnecessary code and I just want you to notice that this so upvoted answer codegolf.stackexchange.com/a/88695/100356 doesn't reset anything either, it requires a new run for every 10x10 block. And most probably the same thing happens in most codes here and in any codegolf question. I don't see any reason why we should use double standards. Jan 19, 2021 at 17:37

# Lua, 31 bytes

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


Try it online!

Not very impressive but I think simpler is shorter in this case.

• can't seem to beat this :) Nov 1, 2021 at 18:21

## Python 3, 26 24 bytes

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

• I'm new to coding and even newer to competitive programming, so don't go too hard on me :D Jan 23, 2021 at 5:01
• Oh of course, multiplication has priority over addition. Thanks dude. Jan 23, 2021 at 5:09

# Whispers v3, 38 bytes

> "**********"
>> Output 1
>> Each 2 1


Try it online!

# BRASCA, 26 24 20 17 bytes

l:[{$[{'*o]xllo$]


Try it online!

## Explanation

l:                   - Initialize stack
[             ]    - Do 10 times:
{$- Decrement and swap [ ] - Do 10 times: {'*o - Decrement and print * xllo$     -   Reset and print a newline


# Python - 40 20 23 bytes

 print(("*"*10+"\n")*10) # prints a row of 10 *s then a new line, 10 times


This (freshly optimised) code prints an asterisk 10 times, then a newline (should be fixed now), then repeats that 10 times.

• Well, a quick save would be with the asterisks, instead of print("**********"), try print("*"*10) and save 6 bytes. Online example here: tio.run/##K6gsycjPM/7/Py2/… Mar 1, 2021 at 14:14
• You can also probably add a newline to the "*"*10, and then multiply that be ten as well Mar 1, 2021 at 14:23
• Fixed now - thanks for the help. Mar 1, 2021 at 14:59
• You don't define the variable n anywhere. Mar 1, 2021 at 16:54
• Um, it doesn't work like that for me. I get NameError: name 'n' is not defined running this code on both Python 2 and Python 3 Mar 2, 2021 at 15:09

# Templates Considered Harmful, 89 bytes

Ap<Fun<If<A<1>,Cat<St<42,42,42,42,42,42,42,42,42,42,10>,Ap<A<0>,Sub<A<1>,T>>>,LF>>,I<10>>


Try it online!

Pretty standard "10 stars 10 times" answer, in the form of a tail-recursive anonymous function.

Ap<
Fun<
If<A<1>,
Cat<
St<42,42,42,42,42,42,42,42,42,42,10>,
Ap<A<0>,
Sub<A<1>,I<1>>>>,
LF>>,
I<10>
>


# naz, 44 40 bytes

crossed out 44 is still regular 44 :(

1x1f6a7m9o1o4d1o0m0x1f1f1f1f1f1f1f1f1f1f


This is another one of those cases where a truly recursive definition would actually use more bytes than just repeating the f instruction.

Saved 4 bytes by using division instead of subtraction!

Try it online!

Explanation (with 0x instructions removed)

1x1f                   # Function 1
6a7m9o1o           # Output 10 asterisks
4d1o       # Output a newline
0m     # Reset the register
1f1f1f1f1f1f1f1f1f1f   # Call function 1 ten times


# JavaScript (V8), 31 bytes

write(**********
.repeat(10))


Try it online!

# Java (JDK), 37 bytes

out.print("**********\n".repeat(10));


Try it online!

# Clojure, 35 bytes

(dotimes[_ 10](print"**********
"))


Try it online!

# Elixir, 35 bytes

for _<-0..9,do: IO.puts"**********"


Try it online!

# VBScript, 39 bytes

For i=0 to 9
WSH.Echo "**********"
next


# VBScript, 53 bytes

For i=0 to 9
WSH.Echo replace(space(10)," ","*")
next


The second solution is slightly more interesting......

# ConTeXt (40 bytes)

Compile it here (note that the magic comment is only here for texlive.net and it's not needed in an offline compilation).

\let~\dorecurse\starttext~{10}{~{10}*\\}


# Twue, 31 bytes

a::~**********\n
::=
aaaaaaaaaa

Try it on the website!

Simply defines the replacement a which maps to printing 10 asterisks. The main body consists of 10 as. Trying a secondary replacement b::=aa or b::=aaaaa both yield 33 bytes, which is unfortunately longer.

Whereas in some Thue interpreters, outputting implicitly outputs a newline, that is not the case in Twue, which must manually insert the newline.

# Duocentehexaquinquagesimal, 18 bytes

hùyy₄āÆβUW:“ã¾8½ž+


Try it online!

# BRASCA, 14 bytes

l[ll['*o{]xo{]


Try it online!

# yuno (abandoned), 11 bytes

」＊１０リュ」ニュア１０リュ


xxd using Jelly's codepage:

00000000: f8f6 e6e5 5bf8 5200 e6e5 5b              ẏẇȧẓ[ẏR¡ȧẓ[


## Explanation

」＊　　　　　　　　　　　　    push "*"
１０　　　　　　　　　　    push 10
リュ　　　　　　　　    repeat "*" 10 times
」ニュ　　　　　    push "\n"
ア　　　　    add / concatenate
１０　　    push 10
リュ    repeat "**********\n" 10 times


Equivalently written as ]*10ryu]nyua10ryu

# PPL, 33 bytes

loop10{
printLine("**********")
}


There is no concept of repeating strings, and the * operator is not overloaded with strings by numbers, so I hardcoded a string of 10 asterisks and printed it 10 times using the loop keyword.

# Mathematica, 24 bytes

Print@@@Table["*",10,10]


A second (simple) Mathematica proposition, same length

# Malbolge, 271 bytes

Generated here (linear generator). I tried other methods too but it took me pretty long time so I could not wait for completion.

D'_:pon}}kXyxx5R-,s0Npn9+k#(EgDU0zyba+u)]xwvunV3210/.-,+*hgH^c\"_AW\UyxwvutsrqpJIHMLEDCg*@E>ba_^]\[ZY9y765.-,+O/.nmJIHGFEDCBAya}|{ts9wvunV3210/.-,+*hgH^c\"_AW\UyxwvutsrqpJIHMLEDCg*@E>ba_^]\[ZY9y765.-,+O/.nmJIHGFEDCBAya}|{ts9wvunV3210/.-,+*hgH^c\"_AW\Uyxwvutsrqp]


Try it online!

## Arduino, 101 bytes

int i=0;void setup(){Serial.begin(300);}void loop(){if(i++<10)Serial.println("**********");else i--;}


The else case is there to prevent i from overflowing and becoming negative, since the loop() function is called indefinitely.

# Python 3, 34 bytes

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


Try it online!

• Welcome to Code Golf! I've edited your answer to make it a bit clearer and added a link to try it. There's a couple similar Python answers, but nice first answer! Oct 1, 2021 at 16:09
• You can save some bytes by inlining the for block, so it can be one line like for i in range(10):print("*"*10) Oct 1, 2021 at 16:09
• Also, make sure to check out our Tips for golfing in Python to see if there are any other ways to golf your code. Oct 1, 2021 at 16:10

# SNOBOL4 (CSNOBOL4), 43 bytes

Outputs two trailing LFs.

 output =dupl(dupl('*',10) char(10),10)
end


Try it online!

• I noticed replacing dupl('*',10) with '**********'` results in number of bytes unchanged.
– user100411
Oct 30, 2021 at 0:52