121
\$\begingroup\$

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.

Task

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.

\$\endgroup\$
10
  • 3
    \$\begingroup\$ @DylanMeeus "You are to print this exact text:" \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 12:56
  • 16
    \$\begingroup\$ @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. \$\endgroup\$
    – James T
    Aug 4, 2016 at 12:58
  • 9
    \$\begingroup\$ @LeakyNun Leaderboard snippet please! \$\endgroup\$
    – anna328p
    Aug 4, 2016 at 22:08
  • 4
    \$\begingroup\$ 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. \$\endgroup\$
    – dwana
    Aug 5, 2016 at 9:14
  • 3
    \$\begingroup\$ you say trailing new lines are acceptable. Are leading newlines acceptable too? \$\endgroup\$ Feb 10, 2017 at 2:34

409 Answers 409

1
2 3 4 5
14
90
\$\begingroup\$

Brainfuck, 47 bytes

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

Try it online!

++++++++++[->++++>+>+<<<]   set the tape to 40 10 10
>++>                        set the tape to 42 10 10
[-<..........>>.<]          come on
\$\endgroup\$
2
  • 61
    \$\begingroup\$ +1 for emoticon in the code >.< \$\endgroup\$
    – user48538
    Aug 4, 2016 at 11:27
  • 36
    \$\begingroup\$ +1 for the fish bones >++> \$\endgroup\$
    – Beta Decay
    Aug 7, 2016 at 23:56
84
\$\begingroup\$

C (gcc), 41 39 bytes

main(i){for(;++i<puts("**********"););}
\$\endgroup\$
7
  • \$\begingroup\$ what version of c? \$\endgroup\$
    – Zaibis
    Aug 4, 2016 at 12:51
  • \$\begingroup\$ @Zaibis Works fine on gcc: coliru.stacked-crooked.com/a/848cb22a00c35c29 . \$\endgroup\$
    – orlp
    Aug 4, 2016 at 13:28
  • 4
    \$\begingroup\$ looks good, good ol' ANSI C. \$\endgroup\$
    – YSC
    Aug 4, 2016 at 13:38
  • 4
    \$\begingroup\$ main(i){while(11-i++)puts("**********");} is an alternative, same length. \$\endgroup\$
    – YSC
    Aug 4, 2016 at 13:41
  • 10
    \$\begingroup\$ I like the clever use of the return from puts() (and of the initial value of i). \$\endgroup\$ Aug 8, 2016 at 14:17
82
\$\begingroup\$

Bash + coreutils, 19 bytes

I prefer to repeat stuff in Bash using 'yes'.

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

I saved 2 bytes by @Neil's suggestion. But when the directory where you are running this command does not only contain files starting with a '.' dot you need to enclose the stars * with ".

Bash + coreutils, 21 bytes

yes "**********"|head
\$\endgroup\$
12
  • 2
    \$\begingroup\$ Great idea to use yes. We usually label such solutions as “Bash + coreutils”. \$\endgroup\$
    – manatwork
    Aug 4, 2016 at 14:58
  • 13
    \$\begingroup\$ Nice that 10 lines coincidentally happens to be the default for head. \$\endgroup\$ Aug 4, 2016 at 15:15
  • 3
    \$\begingroup\$ Can you save two bytes by requiring that any files in the current directory must begin with a .? \$\endgroup\$
    – Neil
    Aug 4, 2016 at 18:51
  • \$\begingroup\$ @Neil, is your comment ment for my answer? If so, I do not get it :) \$\endgroup\$ Aug 4, 2016 at 18:57
  • 1
    \$\begingroup\$ You can also write yes \**********|head without the restriction on files. \$\endgroup\$
    – Florian F
    Aug 10, 2016 at 13:51
56
\$\begingroup\$

Vim, 13 8 bytes

Saved 5 bytes thanks to @Lynn

qqi*␛9.o␛q9@q 

10i*␛Y9p

10i*␛ insert 10 times *, and Y9p copy the line and paste it 9 times.

\$\endgroup\$
9
  • 10
    \$\begingroup\$ 10i*♥Y9p works. \$\endgroup\$
    – Lynn
    Aug 4, 2016 at 11:25
  • 1
    \$\begingroup\$ That's insane vi. \$\endgroup\$ Aug 7, 2016 at 6:53
  • \$\begingroup\$ I think you can count keystrokes instead of bytes for text editors, which means <ESC> would be shorter. \$\endgroup\$
    – addison
    Aug 7, 2016 at 14:55
  • 1
    \$\begingroup\$ Why ♥ and not ␛ ? \$\endgroup\$
    – CL.
    Aug 8, 2016 at 12:54
  • 1
    \$\begingroup\$ I would have used yy9p myself, but nice job using capitals to save a character! \$\endgroup\$
    – Joe Z.
    Aug 12, 2016 at 21:08
55
\$\begingroup\$

Pyth, 6 bytes

VT*T\*

T is 10 in Pyth, Vab executes statement b a times, \* is the asterisk character constant, and multiplying (*) a string and an integer repeats that string n times. Pyth's implicit printing with V means 10 lines are printed.

\$\endgroup\$
0
49
\$\begingroup\$

Hexagony, 37 35 34 31

10"+}(=${";<$<1}42/.0@_=<>\;>(_

Expanded:

   1 0 " +
  } ( = $ {
 " ; < $ < 1
} 4 2 / . 0 @
 _ = < > \ ;
  > ( _ . .
   . . . .

Try it online

Basically just has two for loops counting down from ten to zero, printing out an asterisk on the inner loop, and a newline on the outer loop.

Explanation:

This program consists of three main parts: initialisation of memory, a loop which prints ten asterisks and a loop which prints a newline. The loop which prints a newline also contains the loop which prints the asterisks.

First, the code runs the totally linear memory initialisation. The code works out to be: 10"+}42. This sets the memory of the nearby edges to look like:

10 \ / 10
    |
   42

42 is the ASCII code for the asterisk character, and the two tens will be used as our loop counters. Of note is that the memory pointer is currently pointing away from the two tens, so moving backwards will put us on one of the tens.

Next, we start the astersisk printing loop. Linearly, the code looks like: ;".._(. This prints out an asterisk, moves the memory pointer backwards and to the left and finally decrements the value there. After one iteration, the memory would look like:

10 \ / 9
    |
   42

Then we hit the loop condition: the bottom-leftmost >. If the edge we just decremented is still positive we bounce around and execute a { to move us back onto the 42. Then we hit a $ and return to the beginning of the printing loop, the ;, by skipping the <. If the value was zero, we head into the other loop.

The outer loop begins by resetting the recently zeroed memory edge to ten (this is the 10 in the code, going southwest). Then, we print out this ten as an ASCII character, which is a newline. Next, we move onto the other memory edge and decrement it with {( and then execute what amounts to a bunch of noops: =${_=. Now, after one iteration of this loop, memory would look like:

 9 \ / 10
    |
   42

This time, the memory is facing outwards from the edge storing a nine in the above diagram. Next we execute the < which acts as the loop condition for the outer loop. If the value was non-zero we bounce around off of some mirrors, then begin executing meaningful instructions again after entering the top of the hexagon at the " moving southwest. This causes us to move backwards and to the left, onto the 42 again, but facing inwards. Then the = flips our direction, resetting the state properly to begin the inner loop again. If the edge was set to zero, the instruction pointer goes on a little adventure which does nothing until it exits the program.

The adventure begins by the instruction pointer venturing northeast, perilously disregarding the safety of the cardinal directions. It bravely ignores a mirror that is aligned with its diretion (/) and heroically leaps off of a trampoline ($) entirely evading the deadly trap of another, totally identical trampoline. Staring out at the emptiness of uninitialised hexagon edges, the pointer, without faltering for a moment, adds the two blank edges it faces together, setting the current edge to their sum: 0 (the edge was actually zero beforehand, but the pointer likes to believe this was pretty important). Since the edge is zero, the pointer makes a left turn at the fork in the road, walking into a mysterious forest (of hexagons). There, it finds itself disoriented, moving forwards and backwards and forwards, until it winds up at the same place in memory as it started. Thinking that the problem must be that the current edge was set to zero last time, the pointer bravely plants a 1 into the current edge. Then, the noble pointer investigates another path, one laid with... a trap! The current edge is decremented and set back to zero! The pointer, dazed by the shocking turn of events, stumbles back into the trap setting the current edge to negative one. Infuriated, the pointer attempts to return to the comparatively pleasant forest, only to notice that since the current edge is not positive, the paths have yet again shifted and the pointer finds itself walking into a cave. And by a cave, I mean the mouth of a giant hexagonal worm. Helpless, the pointer curses the sexinity with its dying breath. Also, the program ends.

\$\endgroup\$
2
  • \$\begingroup\$ Golly, I hope the worm was OK with swallowing a pointer. Those things can hurt. \$\endgroup\$
    – Joffan
    Aug 8, 2016 at 4:01
  • 8
    \$\begingroup\$ +1 for writing the most interesting—the only—Hexagony explanation I've ever read. I felt so tense when the edge was decremented! \$\endgroup\$
    – juh
    Aug 28, 2016 at 0:07
44
\$\begingroup\$

Emacs, 10 8 keystrokes

F3 C-1 0 * ENTER F4 C-9 F4

Explanation

F3             Starts a macro recording
C-1 0 *        Apply 10 times command '*': prints 10 asterix'
ENTER          Insert new line
F4             Stops the macro record
C-9 F4         Apply 9 times the macro

Thanks to Sean for saving two keystrokes, suggesting to replace C-udigit with C-digit.

\$\endgroup\$
6
  • 9
    \$\begingroup\$ +1, I always upvote text editor answers (even though I'm more of a vim guy myself) :) \$\endgroup\$
    – DJMcMayhem
    Aug 4, 2016 at 15:10
  • 1
    \$\begingroup\$ If C-u counts as just one keystroke, then you can shave off two strokes by typing C-1 C-0 (or M-1 M-0) instead of C-u 1 0 and C-9 instead of C-u 9. \$\endgroup\$
    – Sean
    Aug 5, 2016 at 14:45
  • 23
    \$\begingroup\$ +1 because you had to suffer through using emacs to write this. \$\endgroup\$
    – addison
    Aug 7, 2016 at 14:54
  • 1
    \$\begingroup\$ Alternatively (saves nothing) the line repetition can be done inside the macro: F3 C-1 0 * ENTER C-1 0 F4 \$\endgroup\$ Aug 9, 2016 at 5:14
  • \$\begingroup\$ @JonathanCarroll yes it would save bytes if we were to print more than 10 lines ;) \$\endgroup\$
    – YSC
    Aug 9, 2016 at 8:28
32
\$\begingroup\$

Jelly, 7 bytes

”*x⁵Ṅ9¡

What's going on?

”*x⁵Ṅ9¡  - No arguments
”*       - character literal, *
  x      - multiply (dyadic operation)
   ⁵     - integer literal, 10 (we have now constructed the string '**********')
    Ṅ    - Print & linefeed (monadic operation)
     9   - integer literal, 9
      ¡  - Repeat n times (n is 9 as the first Ṅ is not a repeat)

Test it on tryitonline

\$\endgroup\$
4
  • 10
    \$\begingroup\$ I really like the Ṅ9¡. \$\endgroup\$
    – Dennis
    Aug 7, 2016 at 20:16
  • \$\begingroup\$ List version: ”*ẋ⁵Wẋ⁵. \$\endgroup\$ Oct 1, 2016 at 14:51
  • \$\begingroup\$ @EriktheGolfer you'd need a Y on the end to "print this exact text" \$\endgroup\$ Oct 1, 2016 at 14:54
  • \$\begingroup\$ @JonathanAllan It is a list on its own, though. It isn't meant to "print this exact text", but, if you want to work on it, you'll use it. \$\endgroup\$ Oct 1, 2016 at 14:55
29
\$\begingroup\$

PowerShell, 14 12 bytes

,('*'*10)*10

Constructs a string of asterisks of length 10 using string multiplication. Encapsulates that in parens and feeds that into the comma-operator to construct an array. We use array multiplication to construct a 10-element array consisting of that element (i.e., a 10-element array of asterisk strings). That's left on the pipeline, and output is implicit (since the default Write-Output for an array is newline-separated, we get that for free -- thanks to @Joey for the clarification).

Older, 14 bytes

0..9|%{'*'*10}

Full program. Loops from 0 to 9 through a ForEach-Object loop |%{...}. Each iteration, we use string multiplication to create a length-10 string of *. Those resulting strings are left on the pipeline, and output at the end is implicit (since the default Write-Output for an array is newline-separated, we get that for free -- thanks to @Joey for the clarification).

\$\endgroup\$
4
  • 6
    \$\begingroup\$ I like it, because powershell can get so verbose. Yet this is elegant and short. \$\endgroup\$
    – dwana
    Aug 4, 2016 at 13:25
  • \$\begingroup\$ Well, technically the array is never passed through a ToString, it's unrolled and passed element by element to Write-Output. In contexts where the array is converted to a string, you get its elements space-separated. \$\endgroup\$
    – Joey
    Aug 9, 2016 at 14:46
  • \$\begingroup\$ @Joey Ah, fair, that's a better way to put it. I'll edit the wording (and my answer template ;-)). \$\endgroup\$ Aug 9, 2016 at 14:58
  • 1
    \$\begingroup\$ I may be biased here because I'm involved with a PowerShell implementation so I had to learn a lot of what actually goes on inside the interpreter ;) \$\endgroup\$
    – Joey
    Aug 9, 2016 at 15:00
26
\$\begingroup\$

V, 7 bytes

10é*10Ä

Try it online!

About as straightforward as an answer can be.

Explanation:

10      "10 times:
  é*    "insert an asterisk
    10Ä "make 10 copies of the current line

5 bytes:

10O±*

Explanation:

10O     " Insert the following on the next ten lines:
   ±    "   10 copies of
    *   "   an asterisk

This didn't work when the challenge was posted because of a bug.

\$\endgroup\$
2
  • \$\begingroup\$ Point of order: é and Ä are multibyte characters (at least in utf-8, as you have them here) so this program is 9 bytes long. \$\endgroup\$
    – rob
    Aug 4, 2016 at 19:35
  • 8
    \$\begingroup\$ @rob They are encoded in utf-8 here, because that's just the way the browser works. V uses "Latin1" encoding, where they are E9 and C4 respectively. \$\endgroup\$
    – DJMcMayhem
    Aug 4, 2016 at 19:41
23
\$\begingroup\$

Jellyfish, 12 10 bytes

Thanks to Zgarb for saving 2 bytes.

P$'*
 &;10

Try it online!

Explanation

Using more conventional notation, this program represents the following expression:

P( $( &;(10), '* ) )

&; takes a single value and creates a pair with two times that value, so &;(10) gives us [10 10]. Then $ is reshape which forms a 10x10 grid of asterisks. Finally, P prints the array in "matrix format" which prints each string on its own line.

\$\endgroup\$
23
\$\begingroup\$

HTML & CSS, 104 60 bytes

p::after{content:"**********"
<p><p><p><p><p><p><p><p><p><p>

I'm unsure if the byte count is correct (as I'm not counting the <style> tags for CSS. The HTML could also be shortened if I used a HTML preprocessor, but I'm unsure if that's breaking rules

Thanks to manatwork and Business Cat.

See my Jade entry of 36 bytes

\$\endgroup\$
18
  • \$\begingroup\$ You can leave out the self closing /s and write all tags in the same line. But better change the tags to <p> as it is shorter even if you need to add p{margin:0}. \$\endgroup\$
    – manatwork
    Aug 5, 2016 at 13:28
  • 2
    \$\begingroup\$ This is not valid css. You need the closing bracket! \$\endgroup\$ Aug 5, 2016 at 16:37
  • 31
    \$\begingroup\$ @RichardHamilton valid css and working css are not the same thing \$\endgroup\$ Aug 7, 2016 at 8:51
  • 2
    \$\begingroup\$ @ClementNerma Why should anyone put code after this? \$\endgroup\$ Sep 13, 2016 at 12:47
  • 3
    \$\begingroup\$ you can leave off the last > I believe \$\endgroup\$
    – 12Me21
    Feb 6, 2017 at 14:47
19
\$\begingroup\$

Python 2, 22 21 bytes

print('*'*10+'\n')*10
\$\endgroup\$
4
  • 3
    \$\begingroup\$ print(("*"*10+'\n')*10) worked for me. \$\endgroup\$
    – piepi
    Aug 7, 2016 at 3:31
  • 8
    \$\begingroup\$ @piepi That's why you're usually better off golfing in Python 2 - you don't need parentheses when calling print. \$\endgroup\$
    – shooqie
    Aug 7, 2016 at 7:41
  • \$\begingroup\$ @shooqie You can't beat a Python3 solution using Python2. Python2 and Python3 are different languages. You also wouldn't compare the Python2 solution to a specialized golf language like Pyth. \$\endgroup\$
    – Alfe
    Oct 14, 2019 at 13:41
  • \$\begingroup\$ Original code prints TypeError: unsupported operand type(s) for *: 'NoneType' and 'int' #Edit didn't notice it was python 2. Piepi's code worked for me \$\endgroup\$
    – Rivered
    Mar 14, 2021 at 2:19
19
\$\begingroup\$

APL, 9 bytes

Works on all APLs ever made.

10 10⍴'*'

10 10 ten rows and ten column

 cyclically repeating

'*' a star

TryAPL online!

\$\endgroup\$
4
  • \$\begingroup\$ It's worth noting that this solution is not Dyalog-specific; it also works with GNU APL. \$\endgroup\$
    – Arc676
    Jun 15, 2017 at 1:20
  • 4
    \$\begingroup\$ @Arc676 True. In fact, it works on all APLs ever made. \$\endgroup\$
    – Adám
    Jun 15, 2017 at 1:26
  • 2
    \$\begingroup\$ argh, I need just one more byte... I almost beat you with the "format" trick: ∘.⊢⍨⍕⍨,⍨5 \$\endgroup\$
    – ngn
    Feb 6, 2018 at 7:50
  • 1
    \$\begingroup\$ @ngn That's wonderfully horrible! \$\endgroup\$
    – Adám
    Feb 6, 2018 at 8:59
18
\$\begingroup\$

Notepad, 34 31 keystrokes

**********
^A^C↓^V^A^C↓^V^V^V^V

^ denotes Ctrl-<following character> keypress, ↑↓ are up and down keys, respectively.

Props to Crypto for 3 saved keystrokes.

\$\endgroup\$
18
  • 2
    \$\begingroup\$ You should use keystrokes to count this. \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 16:08
  • 1
    \$\begingroup\$ That's Shift+Up. Ctrl+Up is something else. \$\endgroup\$
    – Neil
    Aug 4, 2016 at 18:53
  • 1
    \$\begingroup\$ 31 keystrokes **********↵^A^C↓^V^A^C↓^V^V^V^V \$\endgroup\$
    – Crypto
    Aug 5, 2016 at 5:52
  • 1
    \$\begingroup\$ 26 keystrokes *****^A^C^V^V↵^A^C^V^A^C^V^V^V^V^V \$\endgroup\$
    – Andy
    Aug 8, 2016 at 17:24
  • 7
    \$\begingroup\$ 23 keystrokes **^A^C^V^V^V^V^V↵^A^C^V^V^A^C^V^V^V^V^V \$\endgroup\$
    – Andy
    Aug 8, 2016 at 17:26
16
\$\begingroup\$

MATLAB, 14 bytes

repmat('*',10)
\$\endgroup\$
4
  • \$\begingroup\$ I don't have MATLAB to test this, so I'm unsure if this has spaces between the *s. \$\endgroup\$ Oct 1, 2016 at 15:59
  • \$\begingroup\$ @EriktheGolfer clearly not :) \$\endgroup\$
    – PieCot
    Oct 1, 2016 at 19:41
  • \$\begingroup\$ mat suggests a matrix, that's why I asked. \$\endgroup\$ Oct 2, 2016 at 6:23
  • 3
    \$\begingroup\$ @EriktheGolfer excuse me, I was rude. Mat, in fact, refers to a matrix, but in this case is a matrix of char, that is an array of strings (every row is like a string). So, the outupt matrix is printed one row for line, without spaces between elements of the same row. \$\endgroup\$
    – PieCot
    Oct 2, 2016 at 15:07
15
\$\begingroup\$

Java 7, 63 bytes

void f(){for(int i=0;i++<10;)System.out.println("**********");}

Just for kicks. I can't seem to find any tricks to make this shorter. Trying to add logic for a 100-loop or returning a String instead of printing just ends up worse.

\$\endgroup\$
16
  • 1
    \$\begingroup\$ You can shave it off by one byte if you declare i as a class variable (it defaults to 0): int i;void f(){for(;i++<10;)System.out.println("**********");} \$\endgroup\$
    – shooqie
    Aug 4, 2016 at 9:51
  • 3
    \$\begingroup\$ That would break reusability unless I did i=0 somewhere in the function, negating the savings. \$\endgroup\$
    – Geobits
    Aug 4, 2016 at 9:54
  • 3
    \$\begingroup\$ +1 Seems you're indeed right that this is the shortest.. Recursive is 65 bytes: int i=10;void f(){System.out.println("**********");if(i-->0)g();}; One by one recursive is 67 bytes: int i=99;void f(){System.out.print(i%10<1?"*\n":"*");if(i-->0)g();}; Using String-constructor with char-array is 82 bytes: void g(){System.out.print(new String(new char[10]).replace("\0","**********\n"));}; and a String.format is 81 bytes: void g(){System.out.print(String.format("%010d",0).replace("0","**********\n"));}. Ah well, we tried. ;) \$\endgroup\$ Aug 4, 2016 at 11:10
  • 2
    \$\begingroup\$ But does it count without having to add the class declaration itself? What is the shortest java7 full program that can do this? \$\endgroup\$
    – jsbueno
    Aug 4, 2016 at 12:54
  • 1
    \$\begingroup\$ You have to count the import statement, so it wouldn't work for savings here. \$\endgroup\$
    – Geobits
    Aug 7, 2016 at 19:09
14
\$\begingroup\$

Ruby, 15 characters

puts [?**10]*10

Sample run:

bash-4.3$ ruby -e 'puts [?**10]*10'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
\$\endgroup\$
5
  • \$\begingroup\$ Can you explain ?**10? It does indeed create a string of ten asterisks, but I'm unclear how... \$\endgroup\$ Aug 9, 2016 at 0:05
  • 4
    \$\begingroup\$ The ? is the character literal notation, so ?* == '*'. The 2nd * is the String.* method, so ?**10 == '*'.*(10). \$\endgroup\$
    – manatwork
    Aug 9, 2016 at 7:26
  • \$\begingroup\$ Afraid I still don't understand why ? is the literal notation of anything, but perhaps some questions are better left unanswered. ;) \$\endgroup\$ Aug 10, 2016 at 9:09
  • \$\begingroup\$ Sorry, I can't find any reference on this. Is simply the Ruby syntax, which allows various string literal notations plus one in case the string is 1 character long: a ? mark followed by the character, without requiring a closing pair of the ? mark. \$\endgroup\$
    – manatwork
    Aug 10, 2016 at 9:53
  • 1
    \$\begingroup\$ I found it in the reference here: ruby-doc.org/core-2.3.0/doc/syntax/literals_rdoc.html There is also a character literal notation to represent single character strings, which syntax is a question mark (?) followed by a single character or escape sequence that corresponds to a single codepoint in the script encoding: \$\endgroup\$ Aug 11, 2016 at 22:53
14
\$\begingroup\$

Emojicode, 54 bytes

🏁🍇🔂i⏩0 10🍇😀🔤**********🔤🍉🍉

Explanation:

🏁🍇                        👴 The beginning of program.
    🔂 i ⏩ 0 10 🍇          👵 This is called a "range".
                          It basically starts with i=0 and increments until i=10, then exits. 👵
        😀 🔤**********🔤    👵 😀 is printing class.
                          The 🔤s make the characters they surround string literals. 👵
    🍉                     👴 End of range
🍉                         👴 End of program
\$\endgroup\$
2
  • 3
    \$\begingroup\$ I count 54 utf-8 bytes. \$\endgroup\$ Aug 29, 2016 at 2:46
  • \$\begingroup\$ This language hates WIndows 7... \$\endgroup\$ Dec 27, 2016 at 16:11
11
\$\begingroup\$

05AB1E, 7 bytes

TF'*T×,

Explanation

TF      # 10 times do:
  '*T×  # repeat asterisk 10 times
      , # print with newline

Try it online

\$\endgroup\$
2
  • 1
    \$\begingroup\$ т'*×Tô» is another completely different one lol. \$\endgroup\$ Feb 8, 2018 at 15:28
  • \$\begingroup\$ TLú'*ζ» using the zip-filler was another idea... bad one though. \$\endgroup\$ Feb 8, 2018 at 15:40
11
\$\begingroup\$

Brainfuck, 46 43 bytes

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

Try it online! Requires an interpreter with a tape that is open on the left and has 8-bit cells.

The first part of this program +[[---<]+[-->]<] sets up the tape like so:

[255, 250, 245, ... 15, 10, 5, 0, 250, 240, 230, ..., 40, 30, 20, 10, 0]
                                                                      ^

This gives a 40 for outputting asterisks (*, ASCII 42), a 20 to use as a loop counter, and a 10 to use for outputting newlines.

\$\endgroup\$
10
\$\begingroup\$

R, 27 29 bytes

cat(rep('\r**********\n',10))

An alternate answer (34 bytes) is: cat(rep('**********',10),sep='\n')

\$\endgroup\$
7
  • \$\begingroup\$ This adds an extra space at the beginning of all lines except the first (see here ). \$\endgroup\$
    – plannapus
    Aug 4, 2016 at 16:14
  • \$\begingroup\$ Thanks, it works adding \r. \$\endgroup\$
    – Mamie
    Aug 4, 2016 at 19:48
  • 1
    \$\begingroup\$ Another alternative, too many (37) bytes: cat(matrix('*',10,10),fill=10,sep='') r-fiddle \$\endgroup\$ Aug 9, 2016 at 4:48
  • \$\begingroup\$ Another alternative, also 29 bytes: write(rep("*",100),"",10,,"") \$\endgroup\$
    – Giuseppe
    Feb 13, 2018 at 16:14
  • 1
    \$\begingroup\$ And write(rep("**",50),1,5,,"") is 27 bytes and avoids the first carriage return. \$\endgroup\$
    – J.Doe
    Sep 18, 2018 at 8:57
10
\$\begingroup\$

PHP, 32 bytes

for(;$i++<10;)echo"**********
";

(variant 32 bytes - was written with echo)

<?=str_repeat("**********
",10);

(variant 33 bytes)

<?=str_pad("",110,"**********
");

(variant 33 bytes)

for(;$i++<110;)echo$i%11?"*":"
";

(variant 35 bytes)

for(;$i++<10;)printf("%'*10s
",'');

(variant 38 bytes)

<?=($a=str_repeat)($a("*",10)."
",10);
\$\endgroup\$
4
  • 3
    \$\begingroup\$ The second one can be golfed to 32 bytes as well: <?=str_repeat("**********↵",10); \$\endgroup\$ Aug 4, 2016 at 13:41
  • 1
    \$\begingroup\$ As you already have a nice collection of alternatives, here is another for fun: echo chunk_split(str_repeat("*",100),10); The longest so far, just in my vision this is the PHP way to do it. \$\endgroup\$
    – manatwork
    Sep 1, 2016 at 7:37
  • \$\begingroup\$ Can be a byte shorter with WIN-1252 encoding: for(;++$i<111;)echo$i%11?~Õ:~õ; or for(;++$i<11;)echo~ÕÕÕÕÕÕÕÕÕÕõ; \$\endgroup\$
    – aross
    Sep 29, 2016 at 15:50
  • \$\begingroup\$ Another modulo variant for 33 bytes: for(;$i++<110;)echo"*↵"[$i%11<1];. And to add a 37 bytes solution to that collection: for(;$i++<110;)echo chr($i%11?42:10);. \$\endgroup\$
    – Titus
    Jun 9, 2017 at 8:50
8
\$\begingroup\$

MATL, 8 bytes

'*'10tX"

Try it online!

'*'   % Push '*' (string containing an asterisk)
10t   % Push 10 twice
X"    % Repeat the string 10×10 times. Implicitly display
\$\endgroup\$
0
7
\$\begingroup\$

JavaScript (ES6), 37 bytes

console.log(`**********
`.repeat(10))

A straightforward answer.

\$\endgroup\$
2
  • 8
    \$\begingroup\$ Cant you save 6 by using alert ? \$\endgroup\$
    – Kevin L
    Aug 4, 2016 at 12:45
  • 2
    \$\begingroup\$ Arguably you could save 13 bytes by removing the console.log() and specifying REPL in the title. \$\endgroup\$ Aug 4, 2016 at 23:56
7
\$\begingroup\$

Brainfuck, 74 bytes

first brainfuck submission ever, first reasonable length program, too

+++>>+++>>+++++++[<+<+<<+>>>>-]<[>++++++<-]<<<[->++++++++++[>>>.<<<-]>.<<]
+++>>+++>>+++++++[<+<+<<+>>>>-]<[>++++++<-] < sets tape to 10 0 10 0 42

                                           <<< moves to the first 10
            [->++++++++++[>>>.<<<-]>.<<] <
loops while the first cell of the tape is not zero:
    subtracts 1 from first cell
    sets the second cell to 10,
    loops while second cell is not zero: prints 42 cell, subtracts from second cell
    moves to third cell, prints it
\$\endgroup\$
6
  • \$\begingroup\$ 57 bytes \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 11:05
  • \$\begingroup\$ 48 bytes \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 11:06
  • \$\begingroup\$ 47 bytes \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 11:08
  • 14
    \$\begingroup\$ points for trying though, right..? ;_; \$\endgroup\$ Aug 4, 2016 at 11:13
  • \$\begingroup\$ also post the answer yourself \$\endgroup\$ Aug 4, 2016 at 11:14
7
\$\begingroup\$

vim, 8 bytes

10a*<ESC>Y9p

<ESC> is 0x1b.

Annotated

10a*<ESC>  # append * 10 times
Y          # copy line into default register
9p         # paste 9 times

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Congrats on posting in the Language of the Month! \$\endgroup\$
    – Makonede
    Apr 14, 2021 at 22:37
6
\$\begingroup\$

Cheddar, 21 20 bytes

print('*'*10+'
')*10

Yet another straightforward answer.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ Use a literal newline to save 1 byte \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 10:51
  • 2
    \$\begingroup\$ Make it a function using -> instead of print maybe? \$\endgroup\$
    – Downgoat
    Aug 4, 2016 at 19:00
6
\$\begingroup\$

Haskell, 29 bytes

putStr$[0..9]>>"**********\n"

<list1> >> <list2> makes (length <list1>) copies of <list2>.

\$\endgroup\$
6
\$\begingroup\$

Jelly, 8 bytes

”*x³s⁵j⁷

Try it online!

How it works

”*x³s⁵j⁷  Main link. No arguments.

”*        Yield '*'.
  x³      Repeat the character 100 times.
    s⁵    Split into chunks of length 10.
      j⁷  Join, separating by linefeeds.
\$\endgroup\$
5
  • \$\begingroup\$ You finally found a use for the default value of ³. \$\endgroup\$
    – Leaky Nun
    Aug 4, 2016 at 17:12
  • \$\begingroup\$ Here and in Fizz Buzz. \$\endgroup\$
    – Dennis
    Aug 4, 2016 at 17:14
  • \$\begingroup\$ Check it out Dennis...(and what a nice little wrapper you've made!) \$\endgroup\$ Aug 7, 2016 at 19:58
  • \$\begingroup\$ I'm guessing Y wasn't added yet when this was created? If so, now it's -1 byte. \$\endgroup\$ Jun 6, 2018 at 1:26
  • \$\begingroup\$ @AdmBorkBork It was added 8 days after the challenge was posted. :/ \$\endgroup\$
    – Dennis
    Jun 6, 2018 at 2:16
1
2 3 4 5
14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.