87
\$\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
  • 13
    \$\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
  • 6
    \$\begingroup\$ @LeakyNun Leaderboard snippet please! \$\endgroup\$ – dkudriavtsev 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

280 Answers 280

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

Lua, 34 bytes

for i=1,10 do print"**********"end
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Befunge-93 (PyFunge), 28 bytes

#<90v0-1_@#:,
#^_ >1+"*",:9`

Try it online!

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

Javascript (REPL), 27 bytes, Old is 32 bytes. Thanks to @Peter

('**********\n').repeat(10)
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to PPCG! Please note that we count REPL submissions differently from full-program solutions, so this should be marked as "Javascript (REPL)". \$\endgroup\$ – Mego Feb 13 '18 at 2:32
  • \$\begingroup\$ @Mego Thank you, I will remember this! \$\endgroup\$ – NTCG Feb 13 '18 at 2:49
  • \$\begingroup\$ ('**********\n').repeat(10) is shorter :) \$\endgroup\$ – Peter Feb 13 '18 at 21:27
  • \$\begingroup\$ Welcome to PPCG :) Note that this solution already exists: codegolf.stackexchange.com/a/88660/58974. However, you can remove the brackets around the string and use a template literal with a literal newline to save 3 bytes: tio.run/##y0osSyxOLsosKNHNy09J/Z@cn1ecn5Oql5OfrvE/… \$\endgroup\$ – Shaggy Feb 15 '18 at 11:54
2
\$\begingroup\$

Kotlin (script), 32 bytes

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

Try it online!

Run this locally as a standalone program by

  • installing Kotlin
  • saving the source to a .kts file
  • run with kotlinc -script myfile.kts

This does not seem to work on TIO, for whatever reason, which is why I had to include the header/footer.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You could run this as a standalone program using the -script command line switch on kotlin. This doesn't work in TIO/kotlinc though. \$\endgroup\$ – snail_ May 25 '18 at 19:01
  • \$\begingroup\$ I wasn't aware this is possible. If you want to link the script version on TIO, you could do it this way. \$\endgroup\$ – ovs May 25 '18 at 19:35
  • \$\begingroup\$ {print("**********\n".repeat(10))} \$\endgroup\$ – mazzy Jul 2 '18 at 8:18
2
\$\begingroup\$

Kotlin, 62 bytes

fun main(a:Array<String>){for(i in 0..9)println("**********")}

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ your golfed version 37 bytes: {for(i in 0..9)println("**********")}. -3 byte version {print("**********\n".repeat(10))} ))) \$\endgroup\$ – mazzy Jul 2 '18 at 8:15
2
\$\begingroup\$

05AB1E, 9, 8 bytes

Tƒ,TF'*+

my first golfing answer so any tips are welcome

Try it online!

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ That's a grid of 10x9, not 10x10 \$\endgroup\$ – mbomb007 Jul 2 '18 at 14:34
  • \$\begingroup\$ didn't notice that, fixed it @mbomb007 \$\endgroup\$ – Tomb Jul 2 '18 at 14:41
2
\$\begingroup\$

Java (OpenJDK 8), 61 bytes

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

Try it online!

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

MathGolf, 6 bytes

⌂♀*♂/n

Try it online!

Explanation

⌂       Push "*"
 ♀*     Multiply by 100
   ♂/   Divide into chunks of 10
     n  Join with newline

With an output control flag this could be 5 bytes, but I don't have that yet.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Out of curiosity, why is there a single-byte builtin to push the * character? Or are there builtins for *, +, -, and / and some kind of eval functionality for a mathematical expression in string format? \$\endgroup\$ – Kevin Cruijssen Sep 20 '18 at 15:26
  • 2
    \$\begingroup\$ When I made the language, I wanted one single printable character to satisfy printing challenges where any character is valid. Luckily enough, I chose the asterisk! I also have a space character as a single command. \$\endgroup\$ – maxb Sep 20 '18 at 19:01
2
\$\begingroup\$

Stax, 4 bytes

╪n│╔

Run and debug it

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

R 33 bytes

cat(rep('**********',10),sep='
')

Try it online

I believe this is shorter than the other R answers on this question.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I believe this is shorter than yours, but Mamie's answer on the first page (sorted by oldest) is something like 26 bytes if the comments are to be believed. \$\endgroup\$ – Giuseppe Feb 19 '19 at 22:14
  • \$\begingroup\$ Ah, I'd missed that one, thanks @Giuseppe. \$\endgroup\$ – CT Hall Feb 19 '19 at 22:31
2
\$\begingroup\$

Gol><>, 9 bytes

aFa:R`*|H

There is a trailing newline, but the specs say it is okay. Below is a version that doesn't have a trailing new line, but adds on 2 extra bytes.

aFaR`*a|~rH

Try it online!

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

C# (.NET Core), 53 bytes

Brand new to code golf, is this type of format allowed to be used (Usage of the header section / footer section)?

for(int i=0;i<10;i++){Console.Write("**********\n");}

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Welcome to PPCG, and Great First Answer \$\endgroup\$ – Taylor Scott Feb 19 '19 at 22:46
  • \$\begingroup\$ You can get it down to 49 bytes by moving the i++ into the conditional expression, and moving the block body into the increment statement: for(int i=0;i++<10;Console.Write("**********\n")); (try it online) \$\endgroup\$ – mgthomas99 Feb 20 '19 at 14:47
  • 1
    \$\begingroup\$ This is not valid since it's neither a function (lambdas count) nor is it a full program. With a few adjustments though, 42 \$\endgroup\$ – ASCII-only Feb 20 '19 at 16:29
  • \$\begingroup\$ @mgthomas99 btw that's 50 bytes, and it makes no difference whether the write is inside or outside \$\endgroup\$ – ASCII-only Feb 20 '19 at 16:30
2
\$\begingroup\$

Perl 5, 18 Bytes

say'*'x10for 1..10

Requires the -E flags, as in:

perl -E "say'*'x10for 1..10"
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

Forth (gforth), 36 34 bytes

: f 9 for ." **********" cr next ;

Try it online!

-2 bytes thanks to @bubbler

Explanation

 10 0            \ put 10 and 0 on the stack
 do              \ begin a loop from 0 to 10 (0 inclusive 10 exclusive)
 ." **********"  \ print the string literal ********** (the initial space is required because forth words are space separated, and ." is not an exception)
 cr              \ print out a new line character
 loop            \ end the loop
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Using for..next loop is 2 bytes shorter: Try it online! \$\endgroup\$ – Bubbler Oct 12 '19 at 8:13
2
\$\begingroup\$

Keg, 10 bytes

(
|(
|\*)
)

Explanation

(\n|           Start for loop iterating 10 times
    (\n|       Start for loop iterating 10 times
        \*     Push an asterisk
          )    End loop
           \n  Push a newline

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Apparently the final ) is not needed, only the newline in front of it. At least for the TIO version. \$\endgroup\$ – manatwork Oct 14 '19 at 14:20
2
\$\begingroup\$

JAPT, 12 bytes

'*
pA)+R
VpA

Japt sets vars automatically, so '* sets U to "*" pA)+R prints U out A(10) times. And adds a new line (+R). All this is set to V. VpA prints V out A times

In Regular JS is

U = "*";
V = (U.p(A)) + R;
V.p(A)
| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

CSS, 157 109 bytes

Inspired by hd answer, probably 1:1 reproduced from OP question (except background color) - pure CSS solution (no additional HTML)

body:after,body:before{white-space:pre;content:'**********\A**********\A**********\A**********\A**********\A'

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ 103 bytes: *,:after{margin:0;white-space:pre;content:'**********\A**********\A**********\A**********\A**********\A (FireFox only, save it inside <style>...</style> in a totally empty file), the :after matches every element's after (in this case html and body) and * is used to remove the body margin. \$\endgroup\$ – Night2 Oct 15 '19 at 5:43
1
\$\begingroup\$

Racket, 52 bytes

(display(string-join(make-list 10"**********")"\n"))

If you're fine with just returning the string and not printing it, you can forego the (display) for a score of 41 bytes.

An alternate answer (longer at 73 bytes, but I like it better personally):

(display(build-string 110(λ(n)(if(eq?(remainder n 10)0)#\newline #\*))))
| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Batch, 41 bytes

@for /l %%i in (0,1,9)do @echo **********
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You can shave off 1 byte by removing the first @ \$\endgroup\$ – SomethingDark Aug 6 '16 at 3:44
  • \$\begingroup\$ @SomethingDark But then it would print for /l %%i in (0,1,9)do @echo **********... \$\endgroup\$ – Neil Aug 6 '16 at 9:39
  • \$\begingroup\$ It didn't when I tested it \$\endgroup\$ – SomethingDark Aug 6 '16 at 9:39
  • \$\begingroup\$ @SomethingDark You mean as an immediate command? As it's a single line, you might be on to something there. \$\endgroup\$ – Neil Aug 6 '16 at 9:45
  • \$\begingroup\$ As both an immediate command (in which case you could save an additional byte by using %i instead, but I need to double-check the rules for this language) and in a script. \$\endgroup\$ – SomethingDark Aug 6 '16 at 9:46
1
\$\begingroup\$

BASH, 46 bytes

for((n=0;n<10;n++));do echo "**********"; done
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Or for n in {0..9};{ echo "**********";} \$\endgroup\$ – manatwork Aug 4 '16 at 12:43
  • \$\begingroup\$ Or seq -f%10g 10|tr -c \\n \* in Bash + coreutils. \$\endgroup\$ – manatwork Aug 4 '16 at 14:52
1
\$\begingroup\$

C++, 75 bytes

#include<cstdio>
int main(){for(int i=0;i<10;++i)std::puts("**********");}
| improve this answer | |
\$\endgroup\$
  • 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
1
\$\begingroup\$

Frink, 40 39 Bytes

for r=0 to 9
  println[repeat["*",10]]

-1 Byte @LeakNun

| improve this answer | |
\$\endgroup\$
  • 4
    \$\begingroup\$ You can probably use 0 to 9 \$\endgroup\$ – Leaky Nun Aug 4 '16 at 11:18
1
\$\begingroup\$

Maple 30 bytes

printf(cat("**********\n"$10))
| improve this answer | |
\$\endgroup\$
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 2 3
4
5
10

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.