96
\$\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\$
  • 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

305 Answers 305

1
3 4
5
6 7
11
1
\$\begingroup\$

C, 84 bytes

#include<stdio>
int main(){int i;for(i=0;i<10;i++){printf("**********\n");return 0;}

If anyone can improve the answer, I'd appreciate it. I'm not trying to compete, it's just been simply ages since I've coded C or C++ and this challenge looked fun.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Sprects, 22 bytes

#eeep#eppp#pqqq*
#q***

Note: The interpreter uses U+0020 instead of U+0010.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

T-SQL, 50 bytes

print replicate(replicate('*',10)+char(10),10)
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ not an T-SQL expert but wouldn't 'print replicate('**********'+char(10),10)' be shorter? \$\endgroup\$ – dwana Aug 5 '16 at 8:25
1
\$\begingroup\$

C, 47 bytes

main(i){while(i<111)putchar(10|!!(i++%11)<<5);}

Try it online.

Not as compact as the other C answer (putchar is such a long name!), but I don't use the asterisk character in my program. It treats the output as a 11 by 10 grid, where the 11th character is the newline. It then computes the ASCII for '*' (10 + 32 = 42) or '\n' (10) for each position.

I could save one byte with this approach if I were to change the character expression to: 42-!(i++%11)*32, but that would require an asterisk.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

EXCEL, 26 bytes.

=REPT("**********[ae]",10)

Can go into any cell.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What is [ae]? Is that Alt+Enter (the means to input a line break in Excel)? You can include the line break in the code here. It would be 23 bytes total. \$\endgroup\$ – Engineer Toast May 4 '17 at 13:03
1
\$\begingroup\$

tinyAll, 17 bytes

The current version (untouched for a LONG time), is extremelly broken, but works enough for this challenge.

P'*Ra_P"
[:;]"R9_

Basically:

  • Pass * to the R(repeat) function
  • Repeat it a (10) times
  • Output it (_)
  • Pass the output (;), through string interpolation, prefixed by a newline
  • To the R function
  • And repeat 9 more times
  • And display the result

A boring alternative, with the same byte count:

P"**********
"Ra_

Translating:

  • Pass "********** (newline)
  • To the R function, to repeat a (10) times
  • And output the result (_)

Try it:

// Commit https://github.com/ismael-miguel/tinyall/commit/2589837678f4b6556d1bd22f163255e2e058808e#diff-65af36bb0dc600cbc7a54816dcda57fd
(function(window, undefined) {
	var funcs = {
		//echo
		'_':function(value, data){
			var tmp = data.out + (value === undefined ? data.last : value);
			data.vars[';'] = data.out = tmp;
			return tmp;
		},
		//array
		A:function(value, data){
			var split_value = (value || '').split(/(\-?\d+(?:\.\d*)?(?:[eE][\-+]?\d+)?|'(?:\\'|[^']*)*'),?/);
			var final_value = [];
			for(var i = 0, l = split_value.length; i<l; i++)
			{
				if(split_value[i][0] == '\'')
				{
					final_value[final_value.length] = split_value[i].replace(/^'(.*)'$/,'$1').replace(/\\'/g,'\'');
				}
				else if(split_value[i]/1 || split_value[i] == '0')
				{
					final_value[final_value.length] = +split_value[i];
				}
			}
			
			return final_value;
		},
		//comparison functions
		C:function(value, data){
			
		},
		D:function(value, data){
			
			var debug = {
				value: value,
				type: typeof value,
				memory: data
			}
			
			if(console && console.log)
			{
				console.log(debug);
			}
			
			return value;
		},
		//eval
		E:function(value, data){
			run_code(value, data);
		},
		//flip the value around
		F:function(value, data){
			if(('object' === typeof value) && value.reverse)
			{
				return value.reverse();
			}
			else
			{
				return value.toString().split('').reverse().join('');
			}
		},
		//hello worlds
		H:function(value) {
			return 'hH'[value&1]
				+'ello'
				+(value&2?',':'')
				+' '
				+('wW'[+!!(value&4)])
				+'orld'
				+(value&8?'!':'')
				+(value&16?'\n':'');
		},
		//math functions
		M:function(value, data){
			
		},
		//not (inverts values/casing)
		N:function(value) {
			switch(typeof value)
			{
				case 'boolean':
					return !value;
				case 'number':
					return -value;
				case 'string':
					var tmp = '';
					for(var i = 0, l = value.length; i < l; i++)
					{
						if(value[i] >= 'a' && value[i] <= 'z')
						{
							tmp += String.fromCharCode(value.charCodeAt(i) - 32);
						}
						else if(value[i] >= 'A' && value[i] <= 'Z')
						{
							tmp += String.fromCharCode(value.charCodeAt(i) + 32);
						}
						else
						{
							tmp += value[i];
						}
					}
					return tmp;
				default:
					return 0;
			}
		},
		//passthrough
		P:function(value) {
			return value;
		},
		//repeat
		R:function(value, data){
			var tmp = '';
			
			if(value > 0)
			{
				while(value--)
				{
					tmp += data.last;
				}
			}
			
			return tmp;
		},
		//string functions
		S:function(value, data){
			var methods = {
				t:function(value){
					return value.replace(/^\s+/,'').replace(/\s+$/,'');
				},
				u:function(value){
					return value.toUpperCase();
				},
				T:function(value ){
					
				},
				R:function(value){
					
				}
			};
			
			var tmp = data.last.toString();
			for(var i = 0, l = value.length; i < l; i++)
			{
				tmp = value[i] in methods ? methods[value[i]](tmp, value, i) : '';
			}
		
			return tmp;
		},
		//clears output
		Z:function(value, data) {
			return data.vars[';'] = data.out = 0;
		}
	};
	
	var expand_string = function(value, data){
		
		return value.replace(
			/\[:(?:([A-Z_])(.)?|([^A-Z_'"]))\]/g,
			function(_, func, arg, value){
				if(func)
				{
					return funcs[func](get_value(arg, data, true), data);
				}
				else
				{
					return get_value(value, data, true);
				}
			}
		);
		
	};
	
	var get_value = function(value, data, recursion) {
		
		if(value === null || value === undefined || value === ' ')
		{
			return undefined;
		}
		
		var x = (value || '').toString();
		
		if(/^\-?\d+(?:\.\d*)?(?:[eE][\-+]?\d+)?$/.test(x))
		{
			//returns a number
			return +x;
		}
		else if(/^[a-z]$/.test(x))
		{
			//returns a number between 10-43
			return (x in data.vars) ? data.vars[x] : x.charCodeAt(0) - 87;
		}
		else if(x[0] == '\'')
		{
			return x[1];
		}
		else if(x[0] == '"' && x.length >= 2)
		{
			var sub = x.substr(1, x.length - 2);
			
			return recursion ? sub : expand_string(sub, data);
		}
		else
		{
			return data.vars[x];
		}
	};
	
	var run_code = function(code, memory){
		
		if(!code || /^[a-z\d]$/.test(code))
		{
			memory.out = funcs.H(get_value(code, memory));
		}
		else
		{
			code.toString().replace(
				// /(?:([^A-Z_:'"])=)?([A-Z_])(?::('.|"[^"]*"|-?\d+|.))?/g,
				/(?:([^A-Z_'"])=)?([A-Z_])(?:('.|"[^"]*"|-?\d+|[^A-Z_'"]))?/g,
				function(_, name, func, value){
					
					memory.vars[name || ':'] = memory.last = (funcs[func] || noop)( value ? get_value(value, memory) : memory.last, memory);
					
					return '';
				}
			);
		}
	}
	
	var noop = function(){};
	
	window.tinyAll=function(code, input) {
		var data = {
			out: '',
			last: 0,
			input: input || 0,
			vars: {
				//version
				'|':'0.3',
				//input
				':':input || 0,
				//output
				';':0,
				//code
				'.':(code || '').toString()
			}
		};
		
		run_code(data.vars['.'], data);
		
		return data.out || 0;
	};
})(Function('return this')());



//RUN THE CODE!!!
//\n instead of a real newline, but works the same
console.log(tinyAll('P\'*Ra_P"\n[:;]"R9_'));
console.log(tinyAll('P"**********\n"Ra_'));

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PostgreSQL, 39 bytes

select repeat('**********'||chr(13),10)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

99, 137 bytes

99999 9 9
9999 99999 9
999 99 9
999999 99 9




99 99 9 99 9 99 9 99 9999
99
99
99
99
99
99
99
99
99
99
999999
999 999 9
 99 999
 9 99999

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

jq, 24 18 characters

(16 characters code + 2 characters command line option.)

range(10)|"*"*10

Thanks to:

  • Leaky Nun for suggesting to use string multiplication (-6 characters)

Sample run:

bash-4.3$ jq -nr 'range(10)|"*"*10'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********

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

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ range(10)|"*"*10 \$\endgroup\$ – Leaky Nun Aug 5 '16 at 10:58
  • \$\begingroup\$ Thank you, @LeakyNun. No idea why I left with the idea that string*number not works. (array*string is the one that not works.) \$\endgroup\$ – manatwork Aug 5 '16 at 11:02
1
\$\begingroup\$

Pyke, 6 bytes

TVT\**

Try it here!

       - (T = 10)
TV     - repeat(10):
  T\** -  10*"*"
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Go, 84 characters

package main;import"fmt";func main(){for j:=0;j<10;j++{fmt.Println("**********");}}

Sample run:

bash$ go build && ./golf
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Print ten asterisks without using a loop \$\endgroup\$ – Leaky Nun Aug 5 '16 at 15:26
  • \$\begingroup\$ removed inner loop per @LeakyNun \$\endgroup\$ – Tom Scanlan Aug 6 '16 at 2:10
1
\$\begingroup\$

Gibberish, 29 bytes

56ea1[[**********]eo1su1fu]gw

Explanation:

56ea1[[**********]eo1su1fu]gw |
56                            | push 5 and 6
  e                           | switch to first instruction set
   a                          | add a, b
    1                         | push 1
     [[**********]eo1su1fu]   | push string
                           g  | switch to set 3
                            w | while a is 1 execute string as code
      [**********]            | push ten asterisks
                  e           | switch to set 1
                   o          | print a
                    1s        | subtract one
                      u       | duplicate a
                       1      | push 1
                        f     | switch to set 2
                         u    | pop a, b push 1 if a > b else push 0
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Neoscript, 39 bytes

each _=0:[]:9console:log("**********");
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

VBA, 31 bytes

for i=0to 9:?"**********":next

in the VBA Immediate window. I couldn't find any byte-saving tricks beyond this. My best non-loop version was 45 bytes:

?replace("..........",".","**********"&vblf)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Vitsy, 13 bytes

I'm late to the party. :c

a\[aa\['*']Z]

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

PHP 46 bytes

<?php
for($i=-2;++$i<9;)echo "**********\n";?>

I think this don't needs explanation.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

C#, 52 50 49 bytes

49 bytes : 'for(int i=0;i++<10;)Console.Write("**********\n")' (Thanks to Csharpie)

50 bytes : for(int i=0;i<10;i++)Console.Write("**********\n")

52 bytes : for(int i=0;i<10;i++)Console.WriteLine("**********")

Close with 70 bytes : Console.WriteLine(String.Concat(Enumerable.Repeat("**********\n",10)))

edit : Test here : Online C# Interactive compiler.

P.S : C# Interactive is there in Visual Studio/Roslyn for a long time, no one said the answer needs to compile into an executable, or that C# is limited to .NET's verbose BCL functions or that C# is limited to Windows. csi.exe would just be same in functionality as other (interpreted) languages' interpreters do (like PowerShell), which is the beauty of C#.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You might want to include a link to an online interpretter/compiler so we can test your code. e.g. \$\endgroup\$ – Wheat Wizard Aug 5 '16 at 13:10
  • \$\begingroup\$ This would work almost the same as csi.exe included in Roslyn, although the behavior might not be the same for all cases. \$\endgroup\$ – Prajay Basu Aug 5 '16 at 13:25
  • \$\begingroup\$ You can shorten it down a bit for(int i=0;i<10;i++) can be written as for(int i=0;i++<10;) \$\endgroup\$ – CSharpie Aug 8 '16 at 19:38
1
\$\begingroup\$

Swift, 35 Bytes

for _ in 0...9{print("**********")}
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Brachylog, 15 bytes

9ye,"*":9jw@Nw\

Try it online!

Explanation

This exploits backtracking to loop; we create ten useless choice points at the beginning so that it writes ten times the string "**********\n".

9ye,         Pick a number between 0 and 9 (there are thus 10 choice points here)
"*":9j       Concatenate "*" 9 times to itself
w@Nw         Write that string and write a line break
\            False (trigger backtracking: pich another one of the ten numbers)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

MarioLANG, 101 99 95 bytes

Saved 2 bytes thanks to Martin Ender.

Try it Online!

+
++++)+<......(<
++====".======"
+>)+(()>...(.
+====(-=====) -
+++++[!))++ )[!
======#=======#

The left half sets the tape to 10 40 10

The second half increases the 40 to 42, then prints the 42 (*) 10 times, and a newline, and repeats that 10 times.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Link? – – – – – \$\endgroup\$ – Leaky Nun Aug 5 '16 at 17:01
  • \$\begingroup\$ @LeakyNun Sorry I completely forgot. Edited it in. \$\endgroup\$ – Business Cat Aug 5 '16 at 17:06
1
\$\begingroup\$

Convex, 10 bytes

A'**{A*N}%

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Grocery List, 72 bytes

G

number ten
v
z
v
P
s
u
c
l
number ten
l
b
c
p
u
n
s
e
x
u
c
p
b
n
s
e

Try it online

| improve this answer | |
\$\endgroup\$
1
\$\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}'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
| improve this answer | |
\$\endgroup\$
  • 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
1
\$\begingroup\$

LaTeX, 122 110 105 bytes

-12 bytes thanks to @Leaky Nun
-5 bytes by changing package & document type

Or, if I'm allowed to skip the document class definition & setup, and just count the package import and for-loop code: 55 bytes.

I still need to check if there's another package that has a shorter loop syntax, but for now, this simply uses pgffor (from tikz) and a foreach:

\documentclass{book}\usepackage{tikz}\begin{document}\foreach\n in{0,...,9}{**********\par}\end{document}

Ungolfed:

\documentclass{book}
\usepackage{tikz}
\begin{document}
\foreach\n in{0,...,9}{**********\par}
\end{document}

Output (w/ free page number :) ): enter image description here

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ ********** is shorter than \foreach\n in{0,...,9}{*} \$\endgroup\$ – Leaky Nun Aug 14 '16 at 13:54
  • \$\begingroup\$ Good point! Not sure how I missed that... Must've been too focused on getting the nested loop going :) Thanks! \$\endgroup\$ – MH. Aug 14 '16 at 14:10
  • \$\begingroup\$ \\ is shorter than \par \$\endgroup\$ – Leaky Nun Aug 14 '16 at 14:11
  • \$\begingroup\$ True, but then the result is no longer a proper grid as the first line will be indented. \$\endgroup\$ – MH. Aug 14 '16 at 14:27
  • \$\begingroup\$ There's still some room for improvement... I'm pointing to a shorter solution that ALSO includes a free page number AND uses full LaTeX: \documentclass{book}\def~{document}\begin~{\def~{**********\par}~~~~~~~~~~}\end~ uses only 80 bytes. (IMHO: The code should be at most 109 bytes because... you now, I mean, ... 100 times the * character and nine line breaks... So, your version compresses it by 4 bytes which is fine ... ) \$\endgroup\$ – Joe85AC Jun 2 at 15:14
1
\$\begingroup\$

Fortran, 68 51 49 bytes

Skimmed off 17 bytes, because who needs indents and spaces?

-2 bytes thanks to @Joffan

As a tribute to senior and the fact there was no Fortran answer yet. Well, now I know why: this is a pretty hard language to golf! Just one or two indents already take up more bytes than the shortest answer here :)).

program T
do i=0,9
print*,('*',j=0,9)
end do
end

Try it! (ideone)

I tried golfing it down by introducing a nested 'implied' do loop, but the newline character wasn't available until Fortran 2003. Also, it's insanely verbose...

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Loops using 0,9 limits skim off another couple? And make the positive case for not using '**********' :-) \$\endgroup\$ – Joffan Aug 19 '16 at 20:14
  • \$\begingroup\$ Thanks! Not sure how I didn't think of that. Must've had a temporary brain meltdown :/ \$\endgroup\$ – MH. Aug 19 '16 at 21:00
  • \$\begingroup\$ @MH. I know I'm late, but program T print'(10(A))',('*',j=0,99) end is 41 bytes long and doesn't print a leading space :-) \$\endgroup\$ – Phelype Oleinik Oct 15 '19 at 2:58
1
\$\begingroup\$

TI-Basic, 21 bytes

For(I,0,9
Disp "**********
End
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 27 bytes

0{"**********\n"\1+.10<}do;

Try it online!

Explanation

0              # Push 0 onto the stack: counter
{
"**********\n" # Push 10 '*' and a newline character
\              # Moves the counter onto the stack
1+             # Increments the counter
.10<           # Check if it's smaller than 10
}do;           # Repeat until counter equals 10
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ You know, you can just do this \$\endgroup\$ – Leaky Nun Aug 28 '16 at 19:26
  • \$\begingroup\$ I'm a newbie, I didn't know, thank you! \$\endgroup\$ – FedeWar Aug 28 '16 at 19:27
  • \$\begingroup\$ Another byte saved \$\endgroup\$ – Leaky Nun Aug 28 '16 at 19:28
  • \$\begingroup\$ 12 bytes now \$\endgroup\$ – Leaky Nun Aug 28 '16 at 19:29
  • \$\begingroup\$ Wow, I still have a lot to learn. \$\endgroup\$ – FedeWar Aug 28 '16 at 19:30
1
\$\begingroup\$

S.I.L.O.S, 41 bytes

Never used S.I.L.O.S before, can probably be golfed more.

EDIT: Looks like there was already a S.I.L.O.S answer, but it didn't show up on the leaderboard. But I'll keep this answer because it's shorter.

a=10
lblb
printLine **********
a-1
if a b

Try it online!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

GNU sed, 27 bytes

s/^/**********/;h;H;G;H;g;G

To add to the diversity of languages used, I present a sed solution. The code works as follows, indicating the number of sets of 10 asterisks in pattern space and then in hold space:

s/^/**********/        # 10 asterisks are added to pattern space      (1 0)
h                      # overwrites hold space with pattern space     (1 1)
H                      # appends pattern space to hold space          (1 2)
G                      # appends hold space to pattern space          (3 2)
H                      #                                              (3 5)
g                      # overwrites pattern space with hold space     (5 5)
G                      # after G, pattern space is printed on exit   (10 5)
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

BrainFuck, 68 Bytes

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

BrainFuck is fun, this is me practicing my skills.

| improve this answer | |
\$\endgroup\$
1
3 4
5
6 7
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.