100
\$\begingroup\$

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learned 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.

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 88653; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

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

314 Answers 314

1 2
3
4 5
11
3
\$\begingroup\$

Python 3, 25 23 bytes

Hey I actually outgolfed someone :).

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

if stderr is valid, 22 bytes

exit(("*"*9+"*\n")*10)

realised that execing didn't actually golf it down :(


25 bytes answer

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

Works by concatenating ten copies of print('*'*10); and execing, which in turn works by concatenating '*' 10 times and printing

\$\endgroup\$
5
  • \$\begingroup\$ I think you're missing parentheses: print(("*"*9+"*\n")*10) \$\endgroup\$ – shooqie Aug 4 '16 at 9:46
  • \$\begingroup\$ I think you're missing my update \$\endgroup\$ – Destructible Lemon Aug 4 '16 at 9:48
  • \$\begingroup\$ I mean your 21-byte solution gives a wrong output. \$\endgroup\$ – shooqie Aug 4 '16 at 9:52
  • \$\begingroup\$ I'm not sure chronologically which came first the comment or my edit anymore \$\endgroup\$ – Destructible Lemon Aug 4 '16 at 10:25
  • \$\begingroup\$ I didn't even know about that stderr trick, neat! \$\endgroup\$ – sagiksp Feb 17 '17 at 6:11
3
\$\begingroup\$

Same, 239 bytes

ЕEЕEЕEЕEЕEEЕЕEЕEЕEЕЕEΕЕEЕEEЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEΕEEΕEЕΕЕEEЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEЕЕЕЕEΕEEΕЕЕΕΕΕ

Samebly code used to generate this:

add 5
mstore
add 3
mult
add 2
mstore
clear
add 10
while
    minc
    mstore
    mdec
    mread
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    clear
    add 10
    outc
    minc
    mread
    mdec
    dec
end
\$\endgroup\$
3
\$\begingroup\$

><>, 22 15 bytes

'*o'l),lb%a$?$o

The program exits with an error and the output has no trailing newlines. Try it online!

'*o'                  Push 42 '*' and 111
    l),               Divide the 42 by (111 > length of stack) - this is a no-op
                      initially and a division by zero error later on
       lb%            Push (length of stack) % 11
          a$          Put 10 '\n' beneath that
            ?$        If (length of stack) % 11 is nonzero, swap top two chars,
                      moving the '*' above the '\n'
              o       Output top char, leaving the other char and hence
                      increasing the length of the stack by 1

><> is a toroidal 2D language, so the above runs in a loop until the division by zero causes the program to error out.


Alternative 15s (which work for different reasons):

'*o'l),lb%?!{oa
'*o'l),lb%?!}oa
\$\endgroup\$
3
\$\begingroup\$

ArnoldC, 171 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE i
YOU SET US UP 10
STICK AROUND i
TALK TO THE HAND "**********"
GET TO THE CHOPPER i
GET DOWN 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

Just for the fun of it. Nothing fancy going on here, just loops 10 times printing ********** each time.

\$\endgroup\$
1
  • \$\begingroup\$ I think you're missing a HERE IS MY INVITATION i between lines 6 and 7. \$\endgroup\$ – ceilingcat Sep 4 '17 at 3:54
3
\$\begingroup\$

Racket, 43 36 bytes

It's nice to see friendly Racket competition on here :).

(for([i 10])(displayln"**********"))
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Can be shorter with just (i 10) rather than (i (range 10)). \$\endgroup\$ – rnso Sep 6 '16 at 23:11
3
\$\begingroup\$

QBIC, 18 bytes

[1,z:?@**********|

Explanation

`[` starts a for-loop
`@**********|` introduces the string literal "**********" and `?` prints it 
`z` is short for 10
FOR-loops are auto-closed at the end of the program code.

If you'd like me to demonstrate more features of QBIC, upvote this: Showcase of Languages

QBIC's a work-in-progress. The current state would allow us to solve this in 15 bytes:

    [|?@**********`

[ starts a FOR-loop, but the number of arguments is flexible. When | directly follows [, the FOR loop runs from 1 to 10. One argument makes it go from 1 to N, two args runs from M to N and three args introduces an increment:

[3,11,2| --> FOR a=3 TO 11 STEP 2 (or JS-style: for(a=3;a<11;a=a+2){} )
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Maybe put a link to QBIC, for those who aren't familiar with a language? \$\endgroup\$ – user48538 Aug 4 '16 at 9:57
  • \$\begingroup\$ @zyabin101 I've added a link. \$\endgroup\$ – steenbergh Aug 4 '16 at 10:42
3
\$\begingroup\$

Brain-Flak, 77 bytes

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

Try it online!

The naive approach is 91 bytes:

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

But this approach holds an extra ten on the alternate stack to create large numbers easier. Unfortunately, since looping is so expensive in brain-flak, it's actually shorter to just push * 10 times directly rather then setting up a loop to do it.

I'm sure this could be made shorter.

\$\endgroup\$
3
\$\begingroup\$

Javascript: 65 bytes

s="";for(i=1;i<=100;i++){s+="*";if(i%10==0)s+="\n"}console.log(s)

-- After it has been pointed out to me in the comments on the question, that we don't have to care about the dev-tools combining repeated output (as it can be turned off) I rewrote it as following

Javascript: 42 40 bytes

i=10;while(i--)console.log("**********")

(Saved 2 bytes thanks to @kamoroso94)

\$\endgroup\$
4
  • \$\begingroup\$ Better change that if into ternary operator and combine it with previous concatenation: s+="*"+(i%10?"":"\n"). This way, having a single instruction, you can remove the surrounding braces too. \$\endgroup\$ – manatwork Aug 4 '16 at 12:52
  • \$\begingroup\$ Only do the loop to 10, and remove the if.... to add the new line. Spell out the *s and the \n in one string. \$\endgroup\$ – gabe3886 Aug 4 '16 at 12:56
  • \$\begingroup\$ Replace the for loop with i=10;while(i--) to save 2 bytes. \$\endgroup\$ – kamoroso94 Aug 4 '16 at 22:56
  • 2
    \$\begingroup\$ for(i=10;i--;) is even shorter \$\endgroup\$ – Patrick Roberts Aug 4 '16 at 23:58
3
\$\begingroup\$

TSQL, 45 bytes

SELECT TOP 10 REPLICATE('*',10) FROM systypes 

Above query use TSQL REPLICATE function to replicate * 10 times and systypes is a system view in SQL Server which list out system specified and user defined data types.

Try it here

This is my answer on Code Golf and I hope I am doing it correctly.

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to PPCG! I would say you need to count those spaces in your bytecount, since they are required to execute your code \$\endgroup\$ – applejacks01 Aug 4 '16 at 15:30
  • \$\begingroup\$ @applejacks01 Thanks for your input. I have modified it. \$\endgroup\$ – Anuj Tripathi Aug 4 '16 at 15:32
  • 2
    \$\begingroup\$ Couldn't you just do Select top 10 '**********' from systypes? \$\endgroup\$ – pinkfloydx33 Aug 6 '16 at 14:41
  • \$\begingroup\$ Didn't see there was already a TSQL answer. You can do it in 24 bytes by just using Print and "Go 10" \$\endgroup\$ – Paul Feb 12 '18 at 11:25
3
\$\begingroup\$

Wumpus, 22 bytes

)"*"9&=l(&o
}@?!-)9=N}

Try it online!

Explanation:

) increment the counter
 "*" push an asterisk to the stack
    9&= Duplicate it 9 times (leaving 10 copies)
       l(&o Print length of stack-1 times
            Reflect off the end of the line and go South-West
         } Turn right by 60 degrees, now going West along the second line
        N  Print a newline
       =  Duplicate the counter
   !-)9  Check if it is equal to 10
 @? If so, end the program
} Else turn right and go back to the start of the first line
\$\endgroup\$
3
\$\begingroup\$

Rust, 49 bytes

fn main(){print!("{}","**********\n".repeat(10))}

My first code golf answer!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to the site! You might want to add a link to Try It Online with your code, so other people can test your program. \$\endgroup\$ – mabel Jan 22 '20 at 14:06
3
\$\begingroup\$

Flurry, 76 bytes

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

Can be run with the interpreter as follows:

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

Explanation

A function that composes two functions (or multiplies two numbers):

comp = λf g x. f (g x)
     = λf g x. K f x (g x)
     = λf g x. S (K f) g x
     = λf. S (K f)
     = S ∘ K
    := <<>()>

A function that increments a number by one:

succ = λn f x. f (n f x)
     = λn f. comp f (n f)
     = λn f. S comp n f
     = S comp
    := <><<>()>

A function that computes n(n + 1):

oblong = λn. n * succ n
       = λn. comp n [succ n]
       = λn. S comp succ n
       = succ succ
      := <><<>()> [<><<>()]
      := (<><<>()>) {}

The number two:

2 = λf x. f (f x)
  = λf. <f f>
 := {<({}){}>}

The number six:

6 = 2 * 3
  = 2 * succ 2
  = oblong 2
 := oblong {<({}){}>}
 := (<><<>()>){} {<({}){}>}

The number 42 (ASCII value of *):

42 = 6 * 7
   = 6 * succ 6
   = oblong 6
   = oblong (oblong 2)
  := (oblong) [{} 2]
  := ((<><<>()>){}) [{} 2]
  := ((<><<>()>){}) [{} {<({}){}>}]

The number 10:

10 = λf x. f (f (f (f (f (f (f (f (f (f x)))))))))
   = λf. f ∘ f ∘ f ∘ f ∘ f ∘ f ∘ f ∘ f ∘ f ∘ f
   = λf. push (f ∘ f ∘ f ∘ f ∘ f) ∘ pop
   = λf. push (f ∘ push (f ∘ f) ∘ pop) ∘ pop
   = λf. push (push f ∘ push (push pop ∘ pop) ∘ pop) ∘ pop
  := {<  (    < ({})    (    <  ({})     {}>)   {}>)    {}>}
  := {<(<({})(<({}){}>){}>){}>}

A function that pushes 42 to the stack and returns its argument:

push_star = λx. (push 42; x)
          = λx. K x (push 42)
         := {() {} (42)}
         := {() {} (((<><<>()>){})[{}{<({}){}>}])}

A function that takes the number 10 and then pushes ten copies of 42, followed by 10, and returns 10:

push_row = λn. push (n push_star n)
        := { (({}) push_star {}) }
        := { (({}) {(){}(((<><<>()>){})[{}{<({}){}>}])} {}) }

Applying push_row 10 times to the number 10:

main () = 10 push_row 10
        = (push 10) push_row pop
       := (10) push_row {}
       := ({<(<({})(<({}){}>){}>){}>}){(({}){(){}(((<><<>()>){})[{}{<({}){}>}])}{})}{}
\$\endgroup\$
3
\$\begingroup\$

Cubix, 26 bytes

'*u.NNw\./>rroq(?;(?@....N

Try it here

This maps onto a side length 3 cube. Now to try and get rid of some of the no-ops and try and fit it on a side length 2 cube.

      ' * u
      . N N
      w \ .
/ > r r o q ( ? ; ( ? @
. . . . N . . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .
  • / Redirect the flow to the top face
  • '*u Add an * to the stack and u-turn
  • NN Add a couple of 10's to the stack as counters
  • >rroq Rotate the stack to bring the * to the top, output and push it to the bottom
  • (? Decrement the top counter (character) and test.
  • If zero ;( pop from stack, decrement next counter (line), otherwise go around to previous command set.
  • ?@ Test the counter (line) and exit if zero
  • No\w Add a 10 to the stack as a linefeed and a new character counter, output it and redirect back to the > to start the sequence again.
\$\endgroup\$
2
\$\begingroup\$

Python 3, 29 23 bytes

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

Thanks to orlp for shaving off 6 bytes.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ We require either a full program or a function. An expression is not sufficient. \$\endgroup\$ – orlp Aug 4 '16 at 9:35
  • \$\begingroup\$ Yes, I'm referring to your second paragraph. \$\endgroup\$ – orlp Aug 4 '16 at 9:36
  • 1
    \$\begingroup\$ print((10*"*"+"\n")*10) is shorter. \$\endgroup\$ – orlp Aug 4 '16 at 9:37
  • \$\begingroup\$ darnit we had the same answer :( \$\endgroup\$ – Destructible Lemon Aug 4 '16 at 9:50
  • \$\begingroup\$ Changing print to exit will save 1 byte and still output the result, there wasn't specified if it should be printed on standard output. \$\endgroup\$ – Gábor Fekete Aug 4 '16 at 13:50
2
\$\begingroup\$

Golisp, 34 bytes

for[range@10{(_)writeln@*["**"5]}]

Due to a "bug", I can't concatenate strings...

\$\endgroup\$
5
  • \$\begingroup\$ Congratulations! \$\endgroup\$ – Leaky Nun Aug 4 '16 at 10:29
  • \$\begingroup\$ @LeakyNun For what? \$\endgroup\$ – TuxCrafting Aug 4 '16 at 10:30
  • \$\begingroup\$ For developing a language. \$\endgroup\$ – Leaky Nun Aug 4 '16 at 10:30
  • \$\begingroup\$ @LeakyNun Just look at my GitHub repos... \$\endgroup\$ – TuxCrafting Aug 4 '16 at 10:35
  • 7
    \$\begingroup\$ I didn't say "for developing your first language" \$\endgroup\$ – Leaky Nun Aug 4 '16 at 10:35
2
\$\begingroup\$

SpecBAS - 18 bytes

?(("*"*10)+#13)*10

? is shorthand for PRINT, #13 is the equivalent of \n in other languages.

\$\endgroup\$
2
\$\begingroup\$

C#, 79 bytes

class P{void Main(){for(int i=0;i++<10;)System.Console.Write("**********\n");}}
\$\endgroup\$
2
  • \$\begingroup\$ This won't run without static void right? \$\endgroup\$ – pay Aug 4 '16 at 15:49
  • \$\begingroup\$ @pay has void already not sure if it needs static will check later when I have chance \$\endgroup\$ – TheLethalCoder Aug 4 '16 at 15:59
2
\$\begingroup\$

golflua, 22 characters

~@i=0,9 w"**********"$

Sample run:

bash-4.3$ golflua -e '~@i=0,9 w"**********"$'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
\$\endgroup\$
2
\$\begingroup\$

C++, 75 bytes

#include<cstdio>
int main(){for(int i=0;i<10;++i)std::puts("**********");}
\$\endgroup\$
7
  • 2
    \$\begingroup\$ Why the downvote? \$\endgroup\$ – arnsong Aug 4 '16 at 13:00
  • \$\begingroup\$ I believe this was an automatic downvote from the community user. Your post was auto-flagged as low quality (since it only contained code) and Leaky Nun's edit caused an automatic unowned downvote. See meta.stackexchange.com/q/236883 \$\endgroup\$ – FryAmTheEggman Aug 4 '16 at 13:03
  • 2
    \$\begingroup\$ That's actually not true. I don't think it's fair to assume. \$\endgroup\$ – arnsong Aug 4 '16 at 13:55
  • 1
    \$\begingroup\$ You can save 1 byte by changing the for-loop to: for(int i=0;++i<11;) \$\endgroup\$ – Kevin Cruijssen Aug 4 '16 at 14:07
  • 2
    \$\begingroup\$ Use int main(i) and remove the int i=0. Then, replace i<10;++i with i++<10;. -7 \$\endgroup\$ – Erik the Outgolfer Aug 4 '16 at 14:58
2
\$\begingroup\$

Notepad++, ??? keystrokes

I have no idea how to score this, but I decided to give it a shot since there's an answer on Notepad.

Here's the sequence:

* * * * * CTRL (hold) A D D D D D D D D D D

\$\endgroup\$
2
2
\$\begingroup\$

Bash (pure), 30 bytes

printf '%.s**********
' {0..9}

Test it on Ideone.

How it works

Before calling the shell built-in printf, Bash expands the glob {0..9} to 0 1 2 3 4 5 6 7 8 9.

The format string

%.s**********
 

specifies a string whose first 0 characters are included in the output (%.s), followed by ten asterisks and a linefeed. printf repeats the format string as many times as needed to consume all arguments. Since .%s is an empty string, this results in the desired output.

\$\endgroup\$
2
\$\begingroup\$

MSX BASIC, 40 30 bytes

1FORR=1TO10:FORC=1TO10:?"*";:NEXT:?:NEXT

Update: D'oh... much shorter if I just print whole rows:

1FORR=1TO10:?"**********":NEXT
\$\endgroup\$
1
  • \$\begingroup\$ -1 byte: 1FORR=0TO9:?"**********":NEXT \$\endgroup\$ – mazzy Jul 2 '18 at 9:55
2
\$\begingroup\$

Clojure, 38 bytes

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

Simple enough

\$\endgroup\$
2
  • \$\begingroup\$ I'm afraid, that should be 38 bytes. Currently it prints only 8 x 8. \$\endgroup\$ – manatwork Aug 5 '16 at 13:17
  • \$\begingroup\$ You are completely right. I keep posting wrong cases this whole day. \$\endgroup\$ – Michael M Aug 5 '16 at 13:52
2
\$\begingroup\$

Underload, 22 bytes

(*****):*(
)*:*::*:**S
\$\endgroup\$
0
2
\$\begingroup\$

Scheme, 51 Bytes

(map (lambda (n)(display "**********\n"))(iota 10))
\$\endgroup\$
2
\$\begingroup\$

Ruby, 26 20 bytes

10.times{puts'*'*10}

Try it online!

Explanation

Runs 10 times; each time, it prints * (10 times), with an automatic line break at the end.

Kudos to OrangeFlash81 for saving me 6 bytes.

\$\endgroup\$
1
  • \$\begingroup\$ I think 10.times{puts'*'*10} works as well and is shorter. \$\endgroup\$ – Aaron Christiansen Aug 7 '16 at 8:26
2
\$\begingroup\$

Xtend, 33 bytes

[for(_:0..9)print('**********
')]

... a Java dialect; [] is a lambda definition

\$\endgroup\$
2
\$\begingroup\$

Awk, 37 35 characters

BEGIN{for(OFS="*";++i<NF=11;)print}

Thanks to:

  • Cabbie407 for combining the OFS and loop-based solutions (-2 characters)

Sample run:

bash-4.3$ awk 'BEGIN{for(OFS="*";++i<NF=11;)print}'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
\$\endgroup\$
2
  • 1
    \$\begingroup\$ I managed to shorten it by 2 bytes by combining both approaches BEGIN{for(OFS="*";++i<NF=11;)print} \$\endgroup\$ – Cabbie407 Aug 12 '16 at 19:13
  • \$\begingroup\$ Wow! Great catch, @Cabbie407. Thank you. \$\endgroup\$ – manatwork Aug 13 '16 at 10:12
2
\$\begingroup\$

Deadfish ~, 24 bytes

{{iiii}ii{c}{ddd}ddc{d}}

how it works:

{foo} does foo exactly ten times. first, it starts a ten loop, in this loop, it sets the counter to 42, prints it ten times (as char (asterisk)), decrements it to 10, prints it (newline), subtracts 10, then loops again, doing this 10 times.

\$\endgroup\$
2
\$\begingroup\$

Google Sheets, 31 23 bytes

Code:

In cell A1 (12 bytes):

=REPT(B1,10)

In cell B1 (11 bytes):

**********        # Contains New Line
                  # <--

Result:

enter image description here

Previous Attempt #1 (31 bytes):

=REPT(REPT("*",10)&CHAR(10),10)

Previous Attempt #2 (also 31 bytes):

=REPT("**********"&CHAR(10),10)
\$\endgroup\$
1 2
3
4 5
11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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