18
\$\begingroup\$

Create a program which when run displays the text below:

)-*-*-*^_^*-*-*-(
| Welcome User! |
)-*-*-*^_^*-*-*-(

Use any functions or language to answer this, have fun. Shortest code wins

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Can we alternatively return this from a function, as per usual? \$\endgroup\$
    – Stephen
    Commented Jun 20, 2017 at 20:00
  • 7
    \$\begingroup\$ Are leading/trailing newlines allowed? \$\endgroup\$
    – Gryphon
    Commented Jun 20, 2017 at 20:08

53 Answers 53

33
\$\begingroup\$

Python 2, 54 bytes

print(")-*-*-*^_^*-*-*-(\n| Welcome User! |\n"*2)[:53]

Try it online!

\$\endgroup\$
2
  • 7
    \$\begingroup\$ WOW, I'll tattoo this approach on my cerebral cortex!! \$\endgroup\$ Commented Jun 20, 2017 at 20:59
  • \$\begingroup\$ Impressive, beat me by 1 byte! Take a +1 \$\endgroup\$
    – Gryphon
    Commented Jun 21, 2017 at 0:08
12
\$\begingroup\$

T-SQL, 60 bytes

PRINT')-*-*-*^_^*-*-*-(
| Welcome User! |
)-*-*-*^_^*-*-*-('

SQL allows splitting string literals over lines, so those returns are counted.

Working on a procedural solution, but doubt I'll find one under 60.

New Edit: Found a simple REPLACE that ties the trivial solution:

PRINT REPLACE('1
| Welcome User! |
1',1,')-*-*-*^_^*-*-*-(')

Turns out that REPLACE will do an implicit conversion of a numeral to a string, so this lets me save 2 characters by eliminating the quotes around my replacement character.

Trying to put it into a variable is too long, due to the overhead of the DECLARE (69 bytes):

DECLARE @ CHAR(17)=')-*-*-*^_^*-*-*-('PRINT @+'
| Welcome User! |
'+@
\$\endgroup\$
4
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$
    – Joseph
    Commented Jun 20, 2017 at 20:16
  • 8
    \$\begingroup\$ This answer is completely fine @juniorRubyist \$\endgroup\$
    – Mr. Xcoder
    Commented Jun 20, 2017 at 20:16
  • \$\begingroup\$ Ok. I removed that downvote. \$\endgroup\$
    – Joseph
    Commented Jun 20, 2017 at 20:18
  • \$\begingroup\$ Thanks. Thought you were originally referring to the hard-coding the output limitation, but that's allowed for kolmogorov-complexity. Just not particularly efficient. \$\endgroup\$
    – BradC
    Commented Jun 20, 2017 at 20:19
8
\$\begingroup\$

Japt, 41 39 bytes

Saved 2 bytes thanks to @Shaggy

[U="){"-*-*-*^_"ê}("`| WelÖ  U r! |`U]·

Explanation:

[U="){"-*-*-*^_"ê}("`| WelÖ  U r! |`U]·
[                                    ]    // Create a new array
 U=                                       // Variable U =
   ")                                     //   ")
     {            }                       //   Evaluate everything in curley-brackets as code
      "-*-*-*^_"ê                         //   "-*-*-*^_" mirrored -> -*-*-*^_^*-*-*-
                  ("                      //   ("
                                          * Now we have [U=")-*-*-*^_^*-*-*-("]
                    `| WelÖ  U r! |`      // "| Welcome User! |" decompressed by `...`
                                     U    // ")-*-*-*^_^*-*-*-("
                                          * Now we have [")-*-*-*^_^*-*-*-(","| Welcome User! |",")-*-*-*^_^*-*-*-("]
                                      ·   // Split with new-lines

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 39 bytes \$\endgroup\$
    – Shaggy
    Commented Jun 21, 2017 at 9:55
8
\$\begingroup\$

Python 2.7, 55 bytes

a="\n)-*-*-*^_^*-*-*-(\n"
print a+'| Welcome User! |'+a

Pretty simple. Includes leading and trailing newlines.

\$\endgroup\$
1
  • 14
    \$\begingroup\$ It does not need to be a function. \$\endgroup\$ Commented Jun 20, 2017 at 20:17
7
\$\begingroup\$

Bubblegum, 43 bytes

00000000: d3d4 d502 c1b8 f838 30ad abc1 55a3 109e  .......80...U...
00000010: 9a93 9c9f 9baa 105a 9c5a a4a8 50c3 a589  .......Z.Z..P...
00000020: ae06 00bd 4d85 9835 0000 00              ....M..5...

Try it online!

\$\endgroup\$
3
  • 3
    \$\begingroup\$ This language <s>is</s> feels like such an abuse of the "rules", that I think we should change them just so that @Dennis will have to change the language a little \$\endgroup\$
    – Stephen
    Commented Jun 20, 2017 at 20:33
  • \$\begingroup\$ @StephenS TBH, I agree. However, thankfully languages optimized for kolmogorov-complexity (Jelly, 05AB1E, V, SOGL, some others) can still usually beat it without feeling as cheap. \$\endgroup\$
    – DJMcMayhem
    Commented Jun 20, 2017 at 20:34
  • 11
    \$\begingroup\$ @StephenS If a challenge is best solved with Bubblegum, it’s the challenge’s fault, not the language’s. Instead of rules lawyering, write more interesting challenges. \$\endgroup\$ Commented Jun 21, 2017 at 4:57
7
\$\begingroup\$

05AB1E, 31 29 26 bytes

-3 Bytes thanks to Emigna

")-*-*-*^_".∞D”|‡Ý‚Ý! |”s»

Try it online!

Explanation

")-*-*-*^_".∞D”|‡Ý‚Ý! |”s»
")-*-*-*^_"                # Push )-*-*-*^_
           .∞              # Intersected mirror (results in )-*-*-*^_^*-*-*-( )
             D             # Duplicate top of stack
              ”|‡Ý‚Ý! |”   # Pushes | Welcome User! |
                        s  # Swap top items on stack
                         » # Join on newlines
\$\endgroup\$
4
  • 1
    \$\begingroup\$ You could do .∞ instead of û¨'(« \$\endgroup\$
    – Emigna
    Commented Jun 20, 2017 at 20:47
  • \$\begingroup\$ I knew this had to exist somehow! Thanks man \$\endgroup\$
    – Datboi
    Commented Jun 20, 2017 at 20:52
  • \$\begingroup\$ Nevermind, what I posted was equivalent lol. \$\endgroup\$ Commented Jun 21, 2017 at 13:56
  • \$\begingroup\$ I know it's been a while, but you can save a byte by changing the ")-*-*-*^_" to ')„-*Є^_J. :) \$\endgroup\$ Commented Jan 6, 2020 at 14:56
7
\$\begingroup\$

C (gcc), 78 75 bytes

main(i){for(;printf(")-*-*-*^_^*-*-*-(")&i--;puts("\n| Welcome User! |"));}

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Nice try, pretty low amount of bytes as well! \$\endgroup\$
    – Amurt4l
    Commented Jun 20, 2017 at 20:03
  • \$\begingroup\$ Lowest I have got it down to is 66 bytes so far \$\endgroup\$
    – Amurt4l
    Commented Jun 20, 2017 at 20:04
  • \$\begingroup\$ 71 bytes with a trailing newline (75 without): #define P puts(")-*-*-*^_^*-*-*-(") f(){P;puts("| Welcome User! |");P;} \$\endgroup\$
    – Steadybox
    Commented Jun 20, 2017 at 20:11
  • 2
    \$\begingroup\$ @Amurt4l if you would like, since you have gotten quite a few answers, you can post your own answer as well :) \$\endgroup\$
    – Stephen
    Commented Jun 20, 2017 at 20:35
5
\$\begingroup\$

Charcoal, 32 30 bytes

_^×*-³(⸿emocleW |‖B¬J¹¦¹ User!

Try it online! Link is to verbose version of code. Explanation:

_^              Print("_^");
×*-³            Print(Times("*-", 3));
(⸿emocleW |     Print("(\remocleW |");

Prints the mirror image of the top left portion of the output.

‖B¬             ReflectButterfly(:¬);

Reflects down and to the left to create the top and bottom lines and the left of the middle line.

J¹¦¹            JumpTo(1, 1);
 User!          Print(" User!");

Fixes up the middle line.

\$\endgroup\$
2
  • \$\begingroup\$ (Why the downvote?) \$\endgroup\$
    – Neil
    Commented Jun 22, 2017 at 12:15
  • 2
    \$\begingroup\$ Apparently someone's been downvoting many of the answers in this challenge, my submission is also one of the affected ones. \$\endgroup\$
    – user41805
    Commented Jun 22, 2017 at 12:18
4
\$\begingroup\$

Python 3, 62 bytes

print(")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-(")
\$\endgroup\$
7
  • \$\begingroup\$ Needs to be a function. \$\endgroup\$
    – Joseph
    Commented Jun 20, 2017 at 20:12
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$
    – Joseph
    Commented Jun 20, 2017 at 20:16
  • 3
    \$\begingroup\$ But it's not a snippet. It's a full program. \$\endgroup\$ Commented Jun 20, 2017 at 20:17
  • 2
    \$\begingroup\$ No, does not need to be a funciton. Read it again: Use any functions or language to answer this. \$\endgroup\$ Commented Jun 20, 2017 at 20:18
  • 2
    \$\begingroup\$ @juniorRubyist The 1st line of the question says Create a program \$\endgroup\$
    – dzaima
    Commented Jun 20, 2017 at 20:18
4
\$\begingroup\$

///, 42 bytes

/#/)-*-*-*^_^*-*-*-(
/#| Welcome User! |
#

Try it online!

Shorter than the Bubblegum solution!

\$\endgroup\$
1
  • \$\begingroup\$ Why the downvote? \$\endgroup\$
    – sporkl
    Commented Jun 22, 2017 at 14:06
4
\$\begingroup\$

JavaScript, 56 bytes

alert(`${s=")-*-*-*^_^*-*-*-("}
| Welcome User! |
${s}`)

JavaScript (ES6), 50 48 bytes (function)

_=>(s=")-*-*-*^_^*-*-*-(")+`
| Welcome User! |
`+s

-2 bytes thanks to Rick Hitckcock

\$\endgroup\$
6
  • \$\begingroup\$ Why alert? Save a few bytes using a function. \$\endgroup\$
    – Shaggy
    Commented Jun 20, 2017 at 20:11
  • \$\begingroup\$ @Shaggy I know that, just edited it in, but currently OP says display, and has not responded to my comment yet \$\endgroup\$
    – Stephen
    Commented Jun 20, 2017 at 20:12
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$
    – Joseph
    Commented Jun 20, 2017 at 20:16
  • 5
    \$\begingroup\$ @juniorRubyist we usually allow either a complete program or a function. OP did not specify that functions that returned the value instead of displaying it were allowed, so my second two entries may not be allowed. However, complete programs are (almost) always allowed, and JavaScript doesn't need boilerplate. Copy my alert into a .js file and run it in your browser, it'll run. \$\endgroup\$
    – Stephen
    Commented Jun 20, 2017 at 20:19
  • \$\begingroup\$ Save 2 bytes with _=>(s=")-*-*-*^_^*-*-*-(")+\n| Welcome User! |\n+s \$\endgroup\$ Commented Jun 20, 2017 at 21:39
4
\$\begingroup\$

Braingolf, 55 bytes

22#)[#-#*]"^_^"[#*#-]#(V"
| Welcome User! |
"R!&@v&@R&@

Try it online!

It's 2 bytes shorter than hardcoding the output.

Explanation

22                         Push 2 2s to the stack
                             These are used for loop counting
  #)                       Push )
    [#-#*]                 Push -* 3 times, using one of the 2s
          "^_^"            Push ^_^
               [#*#-]      Push *- 3 times, using the remaining 2
                     #(    Push (
                       V   Create a new stack
                        "
| Welcome User! |
"                          Push \n| Welcome User! |\n to the new stack
 R!&@                      Return to main stack, print entire stack without popping
     v&@                   Switch to 2nd stack, pop and print stack
        R                  Return to main stack, pop and print stack
\$\endgroup\$
4
\$\begingroup\$

Perl 5, 49 bytes

print$\=")-*-*-*^_^*-*-*-(","
| Welcome User! |
"

Try it online!

Uses the fact that $\ is implicitly printed after each print.

\$\endgroup\$
2
  • \$\begingroup\$ What about say? \$\endgroup\$
    – simbabque
    Commented Jun 22, 2017 at 13:23
  • 1
    \$\begingroup\$ @simbabque I tend to follow this consensus. Furthermore, replacing all print with say isn't really where the point of golfing lies in my opinion. But I'm not on any crusade to stop using say though; I let everyone do as they like, and everyone is happy :) \$\endgroup\$
    – Dada
    Commented Jun 22, 2017 at 13:32
4
\$\begingroup\$

><>, 56 54 bytes

/a"| !resU emocleW |>"01pa
 l?!;o
/"(-*-*-*^_^*-*-*-)"

Try it online!

2 bytes saved by AGourd

\$\endgroup\$
2
  • \$\begingroup\$ On your first line, you could change |"a">"01p to |>"01pa to save a couple characters \$\endgroup\$
    – AGourd
    Commented Jun 22, 2017 at 13:20
  • \$\begingroup\$ @AGourd; Oh I must have missed that, seems simple when you point it out :) - I'll edit it out soon, thanks. \$\endgroup\$ Commented Jun 22, 2017 at 13:25
3
\$\begingroup\$

C, 75 bytes

main(){char*S=")-*-*-*^_^*-*-*-(";printf("%s\n| Welcome User! |\n%s",S,S);}
\$\endgroup\$
1
  • \$\begingroup\$ 70 bytes like this; m=")-*-*-*^_^*-*-*-(";main(){printf("%s\n| Welcome User! |\n%s",m,m);} \$\endgroup\$
    – cleblanc
    Commented Jun 21, 2017 at 12:59
3
\$\begingroup\$

V, 35 bytes

é)8a-*r(ãhR^_^Äo| Welcome User! |

Try it online!

Hexdump:

00000000: e929 3861 2d2a 1b72 28e3 6852 5e5f 5e1b  .)8a-*.r(.hR^_^.
00000010: c46f 7c20 5765 6c63 6f6d 6520 5573 6572  .o| Welcome User
00000020: 2120 7c                                  ! |

Explanation:

é)                          " Insert a '('
  8a                        " Append 8 copies of the following: 
    -*<esc>                 "   '-*'
           r(               " Replace the last character on this line with '('
             ãh             " Move to the middle of this line
               R            " And write the following text over the existing text:
                ^_^<esc>    "   '^_^'
                        Ä   " Duplicate this line
o                           " On a new line:
 | Welcome User! |          "   Write the whole middle line
\$\endgroup\$
3
\$\begingroup\$

Pyth, 41 bytes

It's boring, but I just cant find a way to creat )-*-*-*^_^*-*-*-( or | Welcome User! | in less bytes than just copying the strings.

J")-*-*-*^_^*-*-*-("J"| Welcome User! |"J

Explanation:
J")-*-*-*^_^*-*-*-("                      # J = ")-*-*-*^_^*-*-*-("
                    J                     # Print J with new line
                     "| Welcome User! |"  # Print "| Welcome User! |" with new line
                                        J # Print J with new line

try it Online

\$\endgroup\$
1
  • \$\begingroup\$ Why the down vote? \$\endgroup\$
    – jacoblaw
    Commented Jun 22, 2017 at 16:07
3
\$\begingroup\$

C# (.NET Core), 60 bytes

_=>")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-("

Try it online!

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

Golang, 82 bytes

func main(){var a string=")-*-*-*^_^*-*-*-(\n";Printf(a+"| Welcome User! |\n"+a)}

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Hello, and welcome to PPCG! Your submission can be a function that returns the text as output, as per meta consensus, which might make it shorter and better for this site. \$\endgroup\$
    – sporkl
    Commented Jun 20, 2017 at 22:11
  • \$\begingroup\$ Ah okay, thank you for the heads up. I'll make an edit. \$\endgroup\$
    – ionk
    Commented Jun 20, 2017 at 22:13
  • \$\begingroup\$ You have to include the fmt import, sorry. \$\endgroup\$ Commented Jun 22, 2017 at 12:44
  • \$\begingroup\$ @totallyhuman wait but it's not part of the function. \$\endgroup\$
    – ionk
    Commented Jun 22, 2017 at 18:53
3
\$\begingroup\$

Sed, 51

Two for the price of one:

s/^/)-*-*-*^_^*-*-*-(/p
x
s/^/| Welcome User! |/p
x

Try it online.

s/^/)-*-*-*^_^*-*-*-(\n| Welcome User! |/p
s/\n.*//

Try it online.

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

MATLAB / Octave, 53 bytes

a=')-*-*-*^_^*-*-*-(';disp([a;'| Welcome User! |';a])
\$\endgroup\$
6
  • \$\begingroup\$ Why MATLAB / Python? This is definitely not valid python. \$\endgroup\$
    – DJMcMayhem
    Commented Jun 21, 2017 at 0:06
  • \$\begingroup\$ @DJMcMayhem Sorry I meant Octave. Thanks for noticing the typo. Been answering python questions over on SO all day so brain had a small glitch :) \$\endgroup\$
    – rayryeng
    Commented Jun 21, 2017 at 0:06
  • \$\begingroup\$ If you ommit disp Matlab will show leading ans = \n. \$\endgroup\$
    – Crowley
    Commented Jun 21, 2017 at 12:31
  • \$\begingroup\$ @Crowley That's why you need the disp there as it won't conform to the exact output. \$\endgroup\$
    – rayryeng
    Commented Jun 21, 2017 at 14:21
  • \$\begingroup\$ If the ans = is not disallowed you can save 6 bytes. \$\endgroup\$
    – Crowley
    Commented Jun 21, 2017 at 16:18
3
\$\begingroup\$

Carrot, 51 bytes

)-*-*-*\^_\^*-*-*-(
^*1//.+/gS"
| Welcome User! |
"

Try it online!

Explanation

)-*-*-*\^_\^*-*-*-(
^                            Give the stack-string this value ")-*-*-*^_^*-*-*-(\n"
 *1                          Append 1 duplicate of the stack-string to itself
                             stack-string: ")-*-*-*^_^*-*-*-(\n)-*-*-*^_^*-*-*-("
//.+/g                       Get matches of /.+/g and set the stack-array to this result
                             stack-array: [")-*-*-*^_^*-*-*-(",")-*-*-*^_^*-*-*-("]
S"
| Welcome User! |
"                            Join the stack-array on "\n| Welcome User! |\n" and
                             set the stack-string to this result
\$\endgroup\$
0
3
\$\begingroup\$

Vim, 38 Bytes

i)^[8a-*^[r(9hR^_^^[Yo| Welcome User! |^[p

Shoutout to the homies in the comments

Original:

i)-\*^[vhyl2pa^_^\*-^[vhyl2pa(^[Vyo| Welcome User! |^[p

Where ^[ is the ESC key

\$\endgroup\$
5
  • 1
    \$\begingroup\$ i)-*-*-*^_^*-*-*-(^] is much shorter for constructing the top line. Also, Y is equivalent to Vy \$\endgroup\$
    – DJMcMayhem
    Commented Jun 21, 2017 at 5:52
  • \$\begingroup\$ Actually if you more or less borrow DJ's V answer top line construction you can save 2 bytes on the hardcode input i)^]8a-*^[r(9hR^_^^[ \$\endgroup\$
    – nmjcman101
    Commented Jun 21, 2017 at 13:01
  • \$\begingroup\$ Thanks y'all. I've been using Vim for like a month and I was just trying to see if I could do it. Obviously I have a lot of optimization to go on my workflow \$\endgroup\$
    – bioweasel
    Commented Jun 21, 2017 at 14:37
  • \$\begingroup\$ One last tip: If duplicate the line before opening a newline for "Welcome User!", you won't need to hit ^[ at the end. YPo| Welcome User! | \$\endgroup\$
    – DJMcMayhem
    Commented Jun 22, 2017 at 16:24
  • \$\begingroup\$ See? didn't even know that P was a thing. That's awesome though. Thanks! \$\endgroup\$
    – bioweasel
    Commented Jun 22, 2017 at 19:36
2
\$\begingroup\$

Mathematica, 52 bytes

Column@{t=")-*-*-*^_^*-*-*-(","| Welcome User! |",t}
\$\endgroup\$
2
\$\begingroup\$

Ruby, 49 bytes

$><<[")-*-*-*^_^*-*-*-("]*2*"
| Welcome User! |
"

Try it online!

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

Minecraft Functions, 77 bytes

tellraw @a {"text":")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-("}
\$\endgroup\$
2
  • \$\begingroup\$ This isn't even trying to compress the string... \$\endgroup\$
    – Okx
    Commented Jun 22, 2017 at 10:07
  • 2
    \$\begingroup\$ @Okx Well try doing that when the only non-constant things you can print are numbers and block/item names :p \$\endgroup\$
    – dzaima
    Commented Jun 22, 2017 at 12:04
2
\$\begingroup\$

PHP, 50 bytes

<?=$a=")-*-*-*^_^*-*-*-(","
| Welcome User! |
$a";

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ <?=$a=")-*-*-*^_^*-*-*-(","\n| Welcome User! |\n$a"; \$\endgroup\$
    – Christoph
    Commented Jun 21, 2017 at 9:32
2
\$\begingroup\$

SOGL V0.12, 27 bytes

↑αMΟ±.○h+‘╬1"→ū↑, ¶‘θ⁾@∑32ž

Try it Here!
I have no idea why I still haven't added a capitalize 1st letter of each word function... Here it uses a 4-byte replacement

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

Batch, 70 bytes

@SET b=@ECHO )-*-*-*^^^^_^^^^*-*-*-(
%b%
@ECHO ^| Welcome User! ^|
%b%

I mostly enjoy this one because all the escape characters make the emoticon ^_^ look like an adorable Lovecraft abomination ^^^^_^^^^

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

Braingolf, 48 bytes

")-*-*-*^_^*-*-*-("!&@"
| Welcome User! |
"@19&@

Try it online!

Explanation

")-*-*-*^_^*-*-*-("        push the string ")-*-*-*^_^*-*-*-(" as characters
                   !&@     print all the characters on the stack without popping
                      "
| Welcome User! |          push the string "\n| Welcome User! |\n"
"
 @19                       pop and print 19 characters on the stack
    &@                     print all the characters on the stack
\$\endgroup\$
0

Your Answer

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

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