111
\$\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 '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\$
    – James T
    Aug 4 '16 at 12:58
  • 7
    \$\begingroup\$ @LeakyNun Leaderboard snippet please! \$\endgroup\$
    – anna328p
    Aug 4 '16 at 22:08
  • 3
    \$\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\$ Feb 10 '17 at 2:34

367 Answers 367

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

Unreadable, 337 319 bytes

'""""""'""'"""'""""""'"""'""'""'""'""'""'""'""'""'""'"""'"""""'""'""""""'""'"""'""""""""'"""""""'""'"""'""""'""""'""""""'""'""'"""'"""""""'"""'"""""'""'""""""'""'""'"""'""""""""'"""""""'""'""'"""'"'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'""'"""""""'"""'"'"""""""'"""

Try it online!

That is quite ... unreadable, have some pseudocode:

Set 2 Set 1 10

While (Increment Set 2 Decrement Get 2)
  Second Second
  Set 3 Get 1
  While (Increment Set 3 Decrement Get 3)
    Print Increment*32 Get 1
  Print Get 1

Transpile it online!

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

Cheddar, 24 bytes

print(['*'*10]*10).vfuse

'*'*10 builds the string **********.

Then, ['**********']*10 creates 10 copies of that string.

Then, vfuse joins by newline.

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

Perl, 17 bytes

Requires -E at no extra cost.

say"*"x10for 0..9

Usage

perl -E 'say"*"x10for 0..9'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********

Saved a byte thanks to @manatwork!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Keywords may touch the preceding digits. \$\endgroup\$
    – manatwork
    Aug 4 '16 at 12:27
  • \$\begingroup\$ @manatwork Ahhh... I always forget that works, expecially as for0.. doesn't! Thanks! \$\endgroup\$ Aug 4 '16 at 12:29
  • 1
    \$\begingroup\$ I literally typed out the same program :) \$\endgroup\$
    – simbabque
    Aug 4 '16 at 14:14
  • 1
    \$\begingroup\$ Try it online! \$\endgroup\$
    – mik
    Mar 15 at 11:52
3
\$\begingroup\$

><>, 35 bytes

ab*1-:?!v:20.
>'*'o72.~
^?%b;!?l<oa

Try it online!

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

dc, 22 18 bytes

[**********]ddddff

Invoked in bash as

echo [**********]ddddff | dc

Explanation:

[**********] # This is dc's way of making a string, which is then pushed onto the stack
dddd         # d is for duplicate, so we duplicate it 4 times on the stack
ff           # print the whole stack twice, which contains 5 repetitions of 10 *'s (x2)

Thanks to LeakyNun for saving 5 4 bytes; Edited from 5 since I can't count.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Ah, right! f doesn't clear the stack. Alternatively, ...dfffff would accomplish it as well with the same byte count. Come to think, ...ddfffp would work just as well (3 sets of three and then just one). There are a lot of ways to get 10 reps with 6 bytes. \$\endgroup\$
    – Delioth
    Aug 4 '16 at 17:45
3
\$\begingroup\$

C#, 53,122 108 bytes

Seeing that I'm seriously new to code golf... I'll give it a shot in c#

public class Program{public static void Main(){for (var i=0;i<10;i++)System.Console.Write("**********\n");}}

try it online

\$\endgroup\$
13
  • \$\begingroup\$ for(var i=0;i++<10;)Console.Write("**********\n"); is shorter, also, you need a full program or function. \$\endgroup\$
    – ASCII-only
    Aug 4 '16 at 11:08
  • \$\begingroup\$ @MarsUltor - thanks for the feedback. As mentioned, I'm seriously new to this and not exactly sure what is allowed and what not. Could you please elaborate on full program? Would this include literary all the code, such as using, namespaces, main etc. Thanks! \$\endgroup\$ Aug 4 '16 at 11:12
  • 2
    \$\begingroup\$ class a{static void Main{for(var i=0;i++<10;)Console.Write("**********\n");}} is acceptable (not entirely sure it works though, you should test it, maybe you need System before Console) \$\endgroup\$
    – ASCII-only
    Aug 4 '16 at 11:21
  • 1
    \$\begingroup\$ You can get rid of using System; and use System.Console.WriteLine("**********");. It saves you 6 bytes. Also, you can get rid of some spaces for extra savings - the ones around the for cycle. \$\endgroup\$
    – auhmaan
    Aug 4 '16 at 17:23
  • 2
    \$\begingroup\$ It's a shame Enumerable.Repeat() is so many bytes... C# could move up a lot of these with a shorthand for that function. \$\endgroup\$ Aug 8 '16 at 19:28
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\$ 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\$ 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\$
1
  • \$\begingroup\$ The github link in the language name is a 404 for me. \$\endgroup\$
    – Bbrk24
    Aug 14 at 13:52
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\$

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\$
5
  • 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
  • \$\begingroup\$ changing BEGIN to END shaves off 2 bytes, at the expense of requiring empty input (which can be justified, IMO), Try it online! \$\endgroup\$
    – mik
    Mar 15 at 12:25
  • \$\begingroup\$ As far as I remember, that time was only allowed for languages where was absolutely no way to make them work without input, for example sed. \$\endgroup\$
    – manatwork
    Mar 15 at 13:53
  • \$\begingroup\$ Just found this, which says that "Programs may assume that input is empty", but I am not sure to which languages it applies. \$\endgroup\$
    – mik
    Mar 15 at 15:47
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\$ Aug 4 '16 at 23:58
3
\$\begingroup\$

JVM Bytecode, 309 bytes

Hexdump output because the entire file is hex:

00000000  ca fe ba be 00 03 00 2d  00 15 01 00 16 28 5b 4c  |.......-.....([L|
00000010  6a 61 76 61 2f 6c 61 6e  67 2f 53 74 72 69 6e 67  |java/lang/String|
00000020  3b 29 56 01 00 08 74 6f  53 74 64 6f 75 74 07 00  |;)V...toStdout..|
00000030  13 07 00 0c 01 00 26 28  4c 6a 61 76 61 2f 6c 61  |......&(Ljava/la|
00000040  6e 67 2f 53 74 72 69 6e  67 3b 29 4c 6a 61 76 61  |ng/String;)Ljava|
00000050  2f 6c 61 6e 67 2f 53 74  72 69 6e 67 3b 01 00 06  |/lang/String;...|
00000060  63 6f 6e 63 61 74 01 00  04 43 6f 64 65 01 00 04  |concat...Code...|
00000070  6d 61 69 6e 01 00 0a 53  6f 75 72 63 65 46 69 6c  |main...SourceFil|
00000080  65 0c 00 06 00 05 0c 00  02 00 12 01 00 10 6a 61  |e.............ja|
00000090  76 61 2f 6c 61 6e 67 2f  53 74 72 69 6e 67 0a 00  |va/lang/String..|
000000a0  03 00 0b 01 00 0b 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |......**********|
000000b0  0a 08 00 0e 0a 00 04 00  0a 07 00 07 01 00 15 28  |...............(|
000000c0  4c 6a 61 76 61 2f 6c 61  6e 67 2f 53 74 72 69 6e  |Ljava/lang/Strin|
000000d0  67 3b 29 56 01 00 15 73  75 6e 2f 6d 69 73 63 2f  |g;)V...sun/misc/|
000000e0  4d 65 73 73 61 67 65 55  74 69 6c 73 01 00 00 00  |MessageUtils....|
000000f0  20 00 11 00 03 00 00 00  00 00 01 00 09 00 08 00  | ...............|
00000100  01 00 01 00 07 00 00 00  22 00 03 00 01 00 00 00  |........".......|
00000110  16 12 0f 59 b6 00 10 59  59 b6 00 10 59 b6 00 10  |...Y...YY...Y...|
00000120  b6 00 10 b8 00 0d b1 00  00 00 00 00 01 00 09 00  |................|
00000130  00 00 02 00 14                                    |.....|
00000135

To minimize size, I:

  • Used the classs name "Code" to avoid putting another entry into the constant table
  • Set the SourceFile to an empty string

  • Used sun.misc.MessageUtils.toStdout() rather than System.out.println() to avoid an extra get static instruction, which also let me avoid having to juggle to keep it on the stack

  • Used exponentially growing dups and String.concat() rather than having a loop
  • Extended the class from sun.misc.MessageUtils to avoid having an entry for java.lang.Object on the stack

The jasmin assembler code used to generate this class is:

.source ""
.class Code
.super sun/misc/MessageUtils
.method public static main([Ljava/lang/String;)V
  .limit stack 3
  ldc "**********\n"
  dup
  invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
  dup
  dup
  invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
  dup
  invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
  invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;
  invokestatic sun/misc/MessageUtils/toStdout(Ljava/lang/String;)V
  return
.end method

and the CFR decompiler output for this class is:

/*
 * Decompiled with CFR 0_125.
 */
import sun.misc.MessageUtils;

class Code
extends MessageUtils {
    public static void main(String[] arrstring) {
        String string = "**********\n".concat("**********\n");
        String string2 = string.concat(string);
        MessageUtils.toStdout(string.concat(string2.concat(string2)));
    }
}
\$\endgroup\$
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
  • 2
    \$\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\$

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'

\$\endgroup\$
1
  • 4
    \$\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
3
\$\begingroup\$

Mornington Crescent, 1940 bytes

Take Northern Line to Euston
Take Victoria Line to Seven Sisters
Take Victoria Line to Euston
Take Victoria Line to Euston
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take District Line to Acton Town
Take Piccadilly Line to Heathrow Terminal 5
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Parsons Green
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross
Take Bakerloo Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

Try it online!

// "*" = 42 = 6*7

// get 7
Take Northern Line to Euston
Take Victoria Line to Seven Sisters

// copy it
Take Victoria Line to Euston
Take Victoria Line to Euston
Take Northern Line to Bank

// add it until 42
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster

// get char "*"
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross

// concatenate it (shorter than with loop)
Take Northern Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington

// calculate a 10 for newline
// get 5 from Heathrow Terminal 5
Take District Line to Acton Town
Take Piccadilly Line to Heathrow Terminal 5
Take Piccadilly Line to Acton Town
Take District Line to Acton Town
Take District Line to Parsons Green

// add 5 + 5
Take District Line to Bank
Take Circle Line to Hammersmith
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Upminster

// get char "\n"
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Charing Cross

// concatenate it with asterisks
Take Bakerloo Line to Paddington

// copy them
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Paddington
Take Circle Line to Bank
Take Circle Line to Hammersmith
Take Circle Line to Paddington
Take Circle Line to Hammersmith
Take Circle Line to Paddington

// go home and print
Take Circle Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent
\$\endgroup\$
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\$
3
\$\begingroup\$

Perl 5, 17 bytes

say'*'x10for 0..9

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ need to print * not x \$\endgroup\$
    – roblogic
    Mar 15 at 1:03
  • 1
    \$\begingroup\$ @roblogic: Thanks for your hint. It was only a small change, of course. \$\endgroup\$
    – Donat
    Mar 15 at 9:04
3
\$\begingroup\$

RAMDISP, 31 bytes.

[P[5[*2]R[M[I[;**********
]]]]]
[P - pipe through the following array
  [
    5 - 5
    [*2] - times 2 [10]
    R - create a range of that size [1..10]
    [M - for each element in that range
      [I - ignore it
        [;**********\n] - print eight asterisks and a newline 
                          (real newline was replaced by \n)
      ]
    ]
  ]
]

basic, but works.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Out of interest, did you make this language? \$\endgroup\$ Jun 25 at 8:19
  • \$\begingroup\$ @RedwolfPrograms yes! but i made it before i even joined stackexchange so i dont think it's cheating \$\endgroup\$ Jun 27 at 20:57
  • 1
    \$\begingroup\$ It wouldn't be cheating either way! In fact, I've got a bounty of +100 reputation for new(ish) languages, and this one looks really interesting. \$\endgroup\$ Jun 27 at 20:59
3
\$\begingroup\$

GForth 36 Bytes

: A 10 0 do ." **********" CR loop ;
\$\endgroup\$
3
\$\begingroup\$

05AB1E, 6 bytes

'*T×v,

Try it online!

'* character literal: "*"
repeat ten times as a string: "**********"
v for each character y in this string:
, print the top of stack. As the stack is empty and there is no input, this uses the value that was previously on the stack, "**********".

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

51AC8, 10 bytes

10[10\*×t]

Try it Online!

Explanation

10[10\*×t]
10          # Push 10 (for each loop; looping var)
   [        # Begin foreach loop (for 10 times)
    10      # Push 10
      \*    # Push '*'
        ×   # Multiply
         t  # Pop and print
          ] # End foreach

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

K (ngn/k), 16 14 13 bytes

` 0:10 10#"*"

Try it online!

Thanks to @Bubbler in the k tree for helping me out with this.

¯2 bytes thanks to @Bubbler

¯1 byte thanks to @Bubbler

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

Cascade, 32 bytes

_9'2
 ^*|
\ !]
(.n
n?\
\%!|
n)+\

Try it online!

One of my more compact Cascade programs. I'm still not sure if it would be shorter to just print 10 asterisks 10 times instead of using a counter, but I'm satisfied with this, especially how the bottom intersects with the top.

Explanation

The easiest way to understand the code is know the basic structure. Each instruction can take up to three inputs, each one below it.

 +
lcr

These are the left, center and right arguments. In this case, the + instruction is dyadic, meaning it takes the left and right arguments. Most instructions are either dyadic or monadic (taking one argument, the center one). The /\| instructions take only the argument they are pointing to, and the ! instructions skips over the center and takes the argument two below it. Each of these arguments can themselves be code instructions, meaning they chain together in a prefix like notation. For example, this code could be represented by the recursive Lisp-like code:

code = (if (0==(n=dec n))
         doboth
           (print (
              if (% n (+9 2)) ('*')
              else (inc 9)
           ))
           (code)
       )

If that doesn't make sense, here's an expanded look at the code, which is still a little confusing, but it at least has an idea of which parts are connected to each other through the |/\Xs. Note that the top and bottom rows are the overlap between the two (and same with the left and right).

\  |/|\ \
 _ 9 ' 2
/ \  |  /
   ^ * |
  / \  | 
 \   ! ]
\ \  \/ \
 ( . n/
 | | |   
 n ? \
  /|\ \  
 \ % ! |
  X \\ | 
 n ) +/\
\  |/|\ \

Starting from the top left corner, we have the first check (_) which executes the right branch only if the left is successful. The left goes down to the ], which sets the n variable (initially 110) to the decrement (() of n, i.e. n=n-1. The check then takes the result of this (the new value of n) and continues if it is positive. This moves onto the branch instruction on the right (^), which executes both the left and right branches.

The left prints (.) the value given by the choice instruction (?). This branches depending on the center value, which is the modulo (%) of n and the addition (+) of 9 and 2. Note that this wraps around to the top again for those digits. If n%(9+2) is 0, then we branch left, which navigates around the % and returns the increment ()) of 9, printing a newline. If it is not divisible by 11, then we go right, skip over the + with a !, and return the character (') of * to print.

Now the right branch of the ^ skips over the n, then goes right, down, and right again, wrapping around both the right edge and the bottom edge to loop back to the _ in the top left. This now loops over the exact same code until n has reached 0, printing ten asterisks and then a newline.

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

Elixir, 35 bytes

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

Try it online!

Originally suggested to @Chester Lynn on their answer.

\$\endgroup\$
1 2
3
4 5
13

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.