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
    Jun 20, 2017 at 20:00
  • 7
    \$\begingroup\$ Are leading/trailing newlines allowed? \$\endgroup\$
    – Gryphon
    Jun 20, 2017 at 20:08

53 Answers 53

1
2
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\$
2
\$\begingroup\$

C, 65 66 bytes

main(){printf("%s| Welcome User! |\n%1$s",")-*-*-*^_^*-*-*-(\n");}

Yes, there are other C solutions, also coming in at about 66 bytes.

Ungolfed

main()
{
    printf("%s| Welcome User! |\n%1$s",
          ")-*-*-*^_^*-*-*-(\n"
          );
}

GCC produces a warning for the missing printf prototype.

The %1$s says use argument 1 (again) for the second string argument.

In real-life programs, it can also be used to pass in precision/width arguments into a printf. This avoids having to use a printf to create the format string for the real printf.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Which compiler successfully compiles and runs this? My gcc (7.1.1) gives an error for the missing semicolon and fails to compile. \$\endgroup\$
    – Doorknob
    Jun 22, 2017 at 2:42
  • \$\begingroup\$ csm@localhost:~$ gcc --version gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \$\endgroup\$
    – CSM
    Jun 22, 2017 at 20:45
  • \$\begingroup\$ I tried compiling gcc 4.9.2 from source on my machine, but I still got an error rather than a warning for the missing semicolon. Is there any other way to reproduce this? \$\endgroup\$
    – Doorknob
    Jun 22, 2017 at 23:53
  • \$\begingroup\$ Argh. You are right, the semicolon is needed. I was accidentally running the previous compilation result. \$\endgroup\$
    – CSM
    Jun 23, 2017 at 12:33
2
\$\begingroup\$

PowerShell, 47 bytes

($z=')-*-*-*^_^*-*-*-(')
"| Welcome User! |
$z"

Try it online!

Ran into the problem everyone else is running into: there's not enough meat to justify trying to encode the top line's pattern. A fancier join method also turned out to cost one more byte

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

Vyxal J, 174 bitsv1, 21.75 bytes

`)-*-*-*^_`øM:`| ÷… ƛ⁼! |`$

Try it Online!

Most likely golfable.

`)-*-*-*^_`                 # literal string
           øM               # flip brackets (`[]()`=>`][)(`) and palindromise
              `| ÷… ƛ⁼! |`  # the compressed string `| Welcome User! |`
             :            $ # put the first string on the top of the stack to wrap it around ^
                            # J flag joins by newlines
\$\endgroup\$
1
\$\begingroup\$

Retina, 42 bytes


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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

bash, 52 bytes

f=")-*-*-*^_^*-*-*-("
echo "$f
| Welcome User! |
$f"
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 88 bytes

fun main(a:Array<String>){val s=")-*-*-*^_^*-*-*-(";print("$s\n| Welcome User! |\n$s")}"
\$\endgroup\$
1
\$\begingroup\$

PHP, 56 52 bytes

<?=$s=")-*-*-*^_^*-*-*-(\n","| Welcome User! |\n$s";
\$\endgroup\$
2
  • \$\begingroup\$ ;echo ──→ , \$\endgroup\$
    – manatwork
    Jun 21, 2017 at 12:03
  • \$\begingroup\$ @manatwork Thanks. I guess you always learn something new every day. \$\endgroup\$
    – Sainan
    Jun 22, 2017 at 10:27
1
\$\begingroup\$

TCL, 73 bytes 54 bytes

set a )-*-*-*^_^*-*-*-( set b "| Welcome User! |" puts " $a\n $b\n $a"


puts "[set a )-*-*-*^_^*-*-*-(]
| Welcome User! |
$a"

Thanks @sergiol for the suggestion!

\$\endgroup\$
1
1
\$\begingroup\$

Stax, 25 bytes

æu√hy╘£.ÅJnc¡┐ßD.P☻Θ╖>╘rÇ

Run and debug it

\$\endgroup\$
1
\$\begingroup\$

Wren, 64 bytes

Fn.new{"1| Welcome User! |
1".replace("1",")-*-*-*^_^*-*-*-(
")}

Try it online!

Explanation

Fn.new{                           // New anonymous function
       "1| Welcome User! |
1"                                // Create the string "| Welcome User! |"
  .replace("1",")-*-*-*^_^*-*-*-(
")}                               // Prepend & append the string ")-*-*-*^_^*-*-*-(\n"
\$\endgroup\$
1
\$\begingroup\$

C (gcc), 63 bytes

f(){printf("%s| Welcome User! |\n%1$s",")-*-*-*^_^*-*-*-(\n");}

Try it online!

Three bytes shorter than all the previous solutions because new rules allow functions.

\$\endgroup\$
1
\$\begingroup\$

C# (Visual C# Interactive Compiler), 57 bytes

Write("{0}\n| Welcome User! |\n{0}",")-*-*-*^_^*-*-*-(");

Try it online!

\$\endgroup\$
1
\$\begingroup\$

C++ (gcc), 127 107 bytes

#include <iostream>
int main(){std::string a="\n)-*-*-*^_^*-*-*-(\n";std::cout<<a;std::cout<<"| Welcome User! |";std::cout<<a;}

Try it online!

Lowered to 107 by noodle man

#include <iostream>
int main(){std::string a="\n)-*-*-*^_^*-*-*-(\n";std::cout<<a<<"| Welcome User! |"<<a;}
\$\endgroup\$
2
0
\$\begingroup\$

PHP, 55 bytes

$a=')-*-*-*^_^*-*-*-(';
echo <<<S
$a
| Welcome User! |
$a
S;
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to PPCG! \$\endgroup\$
    – Laikoni
    Jun 21, 2017 at 21:31
0
\$\begingroup\$

><>, 76 61 bytes

!v"(-*-*-*^_"~! |
 >~")"a"| !resU emocleW |v"61pa10.
l?!;o >
\$\endgroup\$
0
\$\begingroup\$

VBA, 48 Bytes

Anonymous VBE immediate window function that takes no input and outputs a greeting to the user via the immediate window

a=")-*-*-*^_^*-*-*-(":?a:?"| Welcome User! |":?a
\$\endgroup\$
1
  • \$\begingroup\$ I post mine then deleted immediately when I saw yours. :D \$\endgroup\$
    – remoel
    Oct 20, 2017 at 10:13
0
\$\begingroup\$

Golang, 67 Bytes

func n(){a:=")-*-*-*^_^*-*-*-(\n";Print(a+"| Welcome User! |\n"+a)}

Prints with a trailing newline.

Try it online!

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

Canvas, 29 bytes

-*3×^_+)×│| Welcome User! |┌)

Try it here!

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

JavaScript (Node.js), 58 bytes

(u=')-*-*-*^_^*-*-*-(')=>[u,'| Welcome User! |',u].join`
`

Try it online!

I am sure I can golf if down , but later

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

Runic Enchantments, 46 bytes

>")-*-*-*^_^*-*-*-(":$ak"| Welcome User! |"ak@

Try it online!

It will appear to process until it times out, due to the two ^ commands which spawn IPs that do nothing (necessitating the explicit entry >). I am disapointed that this is 2 bytes shorter than the multiple IP method. Constructing the first and last lines using multiplication/duplication turns out to be even more expensive as well (50 bytes). :(

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

R, 61 bytes

r=")-*-*-*^_^*-*-*-(\n";cat(r,"| Welcome User! |\n",r,sep="")

Try it online!

Has a trailing newline. I couldn't see if that was approved or not, so I just rolled with it.

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

PowerShell, 48 bytes

$a=')-*-*-*^_^*-*-*-(';$a;"| Welcome User! |";$a

Try it online!

PowerShell, 54 bytes

$a=')-*-*-*^_^*-*-*-(';write $a;"| Welcome User! |";$a

Try it online!

Old - 68 bytes

Write-Host ")-*-*-*^_^*-*-*-(`n| Welcome User! |`n)-*-*-*^_^*-*-*-("
\$\endgroup\$
1
2

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.