16
\$\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\$
  • 3
    \$\begingroup\$ Can we alternatively return this from a function, as per usual? \$\endgroup\$ – Stephen Jun 20 '17 at 20:00
  • 6
    \$\begingroup\$ Are leading/trailing newlines allowed? \$\endgroup\$ – Gryphon Jun 20 '17 at 20:08

47 Answers 47

6
\$\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
    \$\begingroup\$ 39 bytes \$\endgroup\$ – Shaggy Jun 21 '17 at 9:55
32
\$\begingroup\$

Python 2, 54 bytes

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

Try it online!

\$\endgroup\$
  • 6
    \$\begingroup\$ WOW, I'll tattoo this approach on my cerebral cortex!! \$\endgroup\$ – Mauro Baraldi Jun 20 '17 at 20:59
  • \$\begingroup\$ Impressive, beat me by 1 byte! Take a +1 \$\endgroup\$ – Gryphon Jun 21 '17 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\$
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$ – juniorRubyist Jun 20 '17 at 20:16
  • 8
    \$\begingroup\$ This answer is completely fine @juniorRubyist \$\endgroup\$ – Mr. Xcoder Jun 20 '17 at 20:16
  • \$\begingroup\$ Ok. I removed that downvote. \$\endgroup\$ – juniorRubyist Jun 20 '17 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 Jun 20 '17 at 20:19
9
\$\begingroup\$

Python 2.7, 55 bytes

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

Pretty simple. Includes leading and trailing newlines.

\$\endgroup\$
  • 13
    \$\begingroup\$ It does not need to be a function. \$\endgroup\$ – totallyhuman Jun 20 '17 at 20:17
8
\$\begingroup\$

C (gcc), 78 75 bytes

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

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Nice try, pretty low amount of bytes as well! \$\endgroup\$ – Amurt4l Jun 20 '17 at 20:03
  • \$\begingroup\$ Lowest I have got it down to is 66 bytes so far \$\endgroup\$ – Amurt4l Jun 20 '17 at 20:04
  • \$\begingroup\$ 71 bytes with a trailing newline (75 without): #define P puts(")-*-*-*^_^*-*-*-(") f(){P;puts("| Welcome User! |");P;} \$\endgroup\$ – Steadybox Jun 20 '17 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 Jun 20 '17 at 20:35
6
\$\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
    \$\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 Jun 20 '17 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 Jun 20 '17 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\$ – Anders Kaseorg Jun 21 '17 at 4:57
6
\$\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\$
  • 1
    \$\begingroup\$ You could do .∞ instead of û¨'(« \$\endgroup\$ – Emigna Jun 20 '17 at 20:47
  • \$\begingroup\$ I knew this had to exist somehow! Thanks man \$\endgroup\$ – Datboi Jun 20 '17 at 20:52
  • \$\begingroup\$ Nevermind, what I posted was equivalent lol. \$\endgroup\$ – Magic Octopus Urn Jun 21 '17 at 13:56
5
\$\begingroup\$

Python 3, 62 bytes

print(")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-(")
\$\endgroup\$
  • \$\begingroup\$ Needs to be a function. \$\endgroup\$ – juniorRubyist Jun 20 '17 at 20:12
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$ – juniorRubyist Jun 20 '17 at 20:16
  • 3
    \$\begingroup\$ But it's not a snippet. It's a full program. \$\endgroup\$ – totallyhuman Jun 20 '17 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\$ – Mauro Baraldi Jun 20 '17 at 20:18
  • 2
    \$\begingroup\$ @juniorRubyist The 1st line of the question says Create a program \$\endgroup\$ – dzaima Jun 20 '17 at 20:18
5
\$\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\$
  • \$\begingroup\$ Why alert? Save a few bytes using a function. \$\endgroup\$ – Shaggy Jun 20 '17 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 Jun 20 '17 at 20:12
  • \$\begingroup\$ Please see this: codegolf.meta.stackexchange.com/a/1146/46066 \$\endgroup\$ – juniorRubyist Jun 20 '17 at 20:16
  • 4
    \$\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 Jun 20 '17 at 20:19
  • \$\begingroup\$ Save 2 bytes with _=>(s=")-*-*-*^_^*-*-*-(")+\n| Welcome User! |\n+s \$\endgroup\$ – Rick Hitchcock Jun 20 '17 at 21:39
4
\$\begingroup\$

C, 75 bytes

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

C# (.NET Core), 60 bytes

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

Try it online!

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

MATLAB / Octave, 53 bytes

a=')-*-*-*^_^*-*-*-(';disp([a;'| Welcome User! |';a])
\$\endgroup\$
  • \$\begingroup\$ Why MATLAB / Python? This is definitely not valid python. \$\endgroup\$ – DJMcMayhem Jun 21 '17 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 Jun 21 '17 at 0:06
  • \$\begingroup\$ If you ommit disp Matlab will show leading ans = \n. \$\endgroup\$ – Crowley Jun 21 '17 at 12:31
  • \$\begingroup\$ @Crowley That's why you need the disp there as it won't conform to the exact output. \$\endgroup\$ – rayryeng Jun 21 '17 at 14:21
  • \$\begingroup\$ If the ans = is not disallowed you can save 6 bytes. \$\endgroup\$ – Crowley Jun 21 '17 at 16:18
4
\$\begingroup\$

Perl 5, 49 bytes

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

Try it online!

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

\$\endgroup\$
  • \$\begingroup\$ What about say? \$\endgroup\$ – simbabque Jun 22 '17 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 Jun 22 '17 at 13:32
4
\$\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\$
  • \$\begingroup\$ (Why the downvote?) \$\endgroup\$ – Neil Jun 22 '17 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\$ – Cows quack Jun 22 '17 at 12:18
3
\$\begingroup\$

Mathematica, 52 bytes

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

Golang, 82 bytes

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

Try it online!

\$\endgroup\$
  • \$\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\$ – Comrade SparklePony Jun 20 '17 at 22:11
  • \$\begingroup\$ Ah okay, thank you for the heads up. I'll make an edit. \$\endgroup\$ – ionk Jun 20 '17 at 22:13
  • \$\begingroup\$ You have to include the fmt import, sorry. \$\endgroup\$ – totallyhuman Jun 22 '17 at 12:44
  • \$\begingroup\$ @totallyhuman wait but it's not part of the function. \$\endgroup\$ – ionk Jun 22 '17 at 18:53
3
\$\begingroup\$

Ruby, 49 bytes

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

Try it online!

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

Minecraft Functions, 77 bytes

tellraw @a {"text":")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-("}
\$\endgroup\$
  • \$\begingroup\$ This isn't even trying to compress the string... \$\endgroup\$ – Okx Jun 22 '17 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 Jun 22 '17 at 12:04
3
\$\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\$
3
\$\begingroup\$

PHP, 50 bytes

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

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ <?=$a=")-*-*-*^_^*-*-*-(","\n| Welcome User! |\n$a"; \$\endgroup\$ – Christoph Jun 21 '17 at 9:32
3
\$\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\$
3
\$\begingroup\$

><>, 56 54 bytes

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

Try it online!

2 bytes saved by AGourd

\$\endgroup\$
  • \$\begingroup\$ On your first line, you could change |"a">"01p to |>"01pa to save a couple characters \$\endgroup\$ – AGourd Jun 22 '17 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\$ – Teal pelican Jun 22 '17 at 13:25
2
\$\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\$
2
\$\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\$
  • \$\begingroup\$ Why the down vote? \$\endgroup\$ – jacoblaw Jun 22 '17 at 16:07
2
\$\begingroup\$

///, 42 bytes

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

Try it online!

Shorter than the Bubblegum solution!

\$\endgroup\$
2
\$\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\$
  • \$\begingroup\$ Why the downvote? \$\endgroup\$ – Cows quack Jun 22 '17 at 12:16
2
\$\begingroup\$

bash, 52 bytes

f=")-*-*-*^_^*-*-*-("
echo "$f
| Welcome User! |
$f"
\$\endgroup\$
2
\$\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\$
  • 1
    \$\begingroup\$ i)-*-*-*^_^*-*-*-(^] is much shorter for constructing the top line. Also, Y is equivalent to Vy \$\endgroup\$ – DJMcMayhem Jun 21 '17 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 Jun 21 '17 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 Jun 21 '17 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 Jun 22 '17 at 16:24
  • \$\begingroup\$ See? didn't even know that P was a thing. That's awesome though. Thanks! \$\endgroup\$ – bioweasel Jun 22 '17 at 19:36
2
\$\begingroup\$

Java 8, 62 bytes

x->"".format("%s| Welcome User! |\n%<s",")-*-*-*^_^*-*-*-(\n")

Try it here.

Or as full program (110 bytes):

interface A{static void main(String[]a){System.out.printf("%s| Welcome User! |\n%<s",")-*-*-*^_^*-*-*-(\n");}}

Try it here.

Surprised there wasn't a Java answer yet.

\$\endgroup\$

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.