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
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this communityCreate a program which when run displays the text below:
)-*-*-*^_^*-*-*-(
| Welcome User! |
)-*-*-*^_^*-*-*-(
Use any functions or language to answer this, have fun. Shortest code wins
x->"".format("%s| Welcome User! |\n%<s",")-*-*-*^_^*-*-*-(\n")
Or as full program (110 bytes):
interface A{static void main(String[]a){System.out.printf("%s| Welcome User! |\n%<s",")-*-*-*^_^*-*-*-(\n");}}
Surprised there wasn't a Java answer yet.
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.
gcc
(7.1.1) gives an error for the missing semicolon and fails to compile.
\$\endgroup\$
($z=')-*-*-*^_^*-*-*-(')
"| Welcome User! |
$z"
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
J
, 174 bitsv1, 21.75 bytes`)-*-*-*^_`øM:`| ÷… ƛ⁼! |`$
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
f=")-*-*-*^_^*-*-*-("
echo "$f
| Welcome User! |
$f"
fun main(a:Array<String>){val s=")-*-*-*^_^*-*-*-(";print("$s\n| Welcome User! |\n$s")}"
set a )-*-*-*^_^*-*-*-(
set b "| Welcome User! |"
puts " $a\n $b\n $a"
puts "[set a )-*-*-*^_^*-*-*-(]
| Welcome User! |
$a"
Thanks @sergiol for the suggestion!
Fn.new{"1| Welcome User! |
1".replace("1",")-*-*-*^_^*-*-*-(
")}
Fn.new{ // New anonymous function
"1| Welcome User! |
1" // Create the string "| Welcome User! |"
.replace("1",")-*-*-*^_^*-*-*-(
")} // Prepend & append the string ")-*-*-*^_^*-*-*-(\n"
f(){printf("%s| Welcome User! |\n%1$s",")-*-*-*^_^*-*-*-(\n");}
Three bytes shorter than all the previous solutions because new rules allow functions.
Write("{0}\n| Welcome User! |\n{0}",")-*-*-*^_^*-*-*-(");
#include <iostream>
int main(){std::string a="\n)-*-*-*^_^*-*-*-(\n";std::cout<<a;std::cout<<"| Welcome User! |";std::cout<<a;}
Lowered to 107 by noodle man
#include <iostream>
int main(){std::string a="\n)-*-*-*^_^*-*-*-(\n";std::cout<<a<<"| Welcome User! |"<<a;}
$a=')-*-*-*^_^*-*-*-(';
echo <<<S
$a
| Welcome User! |
$a
S;
!v"(-*-*-*^_"~! |
>~")"a"| !resU emocleW |v"61pa10.
l?!;o >
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
func n(){a:=")-*-*-*^_^*-*-*-(\n";Print(a+"| Welcome User! |\n"+a)}
Prints with a trailing newline.
(u=')-*-*-*^_^*-*-*-(')=>[u,'| Welcome User! |',u].join`
`
I am sure I can golf if down , but later
>")-*-*-*^_^*-*-*-(":$ak"| Welcome User! |"ak@
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). :(
r=")-*-*-*^_^*-*-*-(\n";cat(r,"| Welcome User! |\n",r,sep="")
Has a trailing newline. I couldn't see if that was approved or not, so I just rolled with it.
$a=')-*-*-*^_^*-*-*-(';$a;"| Welcome User! |";$a
$a=')-*-*-*^_^*-*-*-(';write $a;"| Welcome User! |";$a
Write-Host ")-*-*-*^_^*-*-*-(`n| Welcome User! |`n)-*-*-*^_^*-*-*-("