问候用户


16

创建一个程序,该程序在运行时显示以下文本:

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

使用任何功能或语言来回答这个问题,玩得开心。最短代码胜出


3
我们可以像往常一样从函数中返回它吗?
Stephen

6
是否允许前导/尾随换行符?
狮ry

Answers:


6

Japt41 39字节

@Shaggy节省了2个字节

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

说明:

[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

在线尝试!




12

T-SQL,60个字节

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

SQL允许在行之间分割字符串文字,因此将这些返回值计算在内。

致力于程序解决方案,但我怀疑会发现60岁以下的解决方案。

新建:找到了一个REPLACE将平凡的解决方案联系在一起的简单方法:

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

事实证明,REPLACE这样做会将数字隐式转换为字符串,因此,通过消除替换字符周围的引号,可以节省2个字符。

由于DECLARE(69字节)的开销,尝试将其放入变量太长:

DECLARE @ CHAR(17)=')-*-*-*^_^*-*-*-('PRINT @+'
| Welcome User! |
'+@


8
这个答案是完全正确的@juniorRubyist
Xcoder先生17年

好。我删除了那张选票。
juniorRubyist

谢谢。以为您最初指的是对输出限制进行硬编码,但是允许kolmogorov-complexity。只是不是特别有效。
BradC

9

Python 2.7,55个字节

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

很简单 包括前导和尾随的换行符。


13
它不必是一个函数。
6


6

泡泡糖,43个字节

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...

在线尝试!


3
这种语言感觉就像是对“规则”的滥用,我认为我们应该更改它们,以便@Dennis将不得不稍微更改语言
Stephen

@StephenS TBH,我同意。但是,值得庆幸的是,针对kolmogorov复杂度进行了优化的语言(Jelly,05AB1E,V,SOGL和其他一些语言)通常仍然可以击败它而不会觉得便宜。
DJMcMayhem

11
@StephenS如果使用Bubblegum最好地解决了挑战,那是挑战的错,而不是语言的错。与其制定规则,不如编写更多有趣的挑战。
Anders Kaseorg

6

05AB1E31 29 26字节

-3字节归功于Emigna

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

在线尝试!

说明

")-*-*-*^_".∞D”|‡Ý‚Ý! |”s»
")-*-*-*^_"                # Push )-*-*-*^_
           .∞              # Intersected mirror (results in )-*-*-*^_^*-*-*-( )
             D             # Duplicate top of stack
              ”|‡Ý‚Ý! |”   # Pushes | Welcome User! |
                        s  # Swap top items on stack
                         » # Join on newlines

1
您可以.∞代替û¨'(«
Emigna

我知道这一定存在!谢谢男人
Datboi

没关系,我发布的内容与之相当。
Magic Octopus Urn

我知道已经有一段时间了,但是您可以通过将更")-*-*-*^_"改为来保存一个字节')„-*Є^_J。:)
Kevin Cruijssen


5

JavaScript,56个字节

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

JavaScript(ES6),50个48字节(功能)

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

-2个字节,感谢Rick Hitckcock


为什么alert呢 使用函数保存一些字节。
毛茸茸的

@Shaggy我知道,只是对其进行了编辑,但是当前OP表示显示,并且尚未回复我的评论
Stephen


4
@juniorRubyist我们通常允许使用完整的程序或函数。OP没有指定允许返回值而不是显示它的函数,因此可能不允许我的后两个条目。但是,(几乎)总是允许使用完整程序,并且JavaScript不需要样板。将my复制alert.js文件中并在浏览器中运行,它将运行。
斯蒂芬

使用_=>(s=")-*-*-*^_^*-*-*-(")+\ n | 保存2个字节 欢迎用户!| \ n+s
里克·希区柯克




4

MATLAB /八度,53字节

a=')-*-*-*^_^*-*-*-(';disp([a;'| Welcome User! |';a])

为什么MATLAB / Python呢 这绝对不是有效的python。
DJMcMayhem

@DJMcMayhem对不起,我的意思是八度。感谢您注意拼写错误。整天都在回答python问题,所以大脑出现了一个小故障:)
rayryeng-恢复莫妮卡(Monica)

如果省略,dispMatlab将显示领先地位ans = \n
克劳利

@Crowley这就是为什么您需要disp那里的原因,因为它与确切的输出不一致。
rayryeng-恢复莫妮卡

如果ans = 不禁止,则可以保存6个字节。
克劳利

4

Perl 5,49个字节

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

在线尝试!

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


What about say?
simbabque

1
@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 :)
Dada

4

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.


(Why the downvote?)
Neil

2
Apparently someone's been downvoting many of the answers in this challenge, my submission is also one of the affected ones.
Kritixi Lithos

3

Mathematica, 52 bytes

Column@{t=")-*-*-*^_^*-*-*-(","| Welcome User! |",t}

3

Golang, 82 bytes

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

Try it online!


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.
Comrade SparklePony

Ah okay, thank you for the heads up. I'll make an edit.
ionk

You have to include the fmt import, sorry.
totallyhuman

@totallyhuman wait but it's not part of the function.
ionk


3

Minecraft Functions, 77 bytes

tellraw @a {"text":")-*-*-*^_^*-*-*-(\n| Welcome User! |\n)-*-*-*^_^*-*-*-("}

This isn't even trying to compress the string...
Okx

2
@Okx Well try doing that when the only non-constant things you can print are numbers and block/item names :p
dzaima

3

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


3

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 ^^^^_^^^^


3

><>, 56 54 bytes

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

Try it online!

2 bytes saved by AGourd


On your first line, you could change |"a">"01p to |>"01pa to save a couple characters
AGourd

@AGourd; Oh I must have missed that, seems simple when you point it out :) - I'll edit it out soon, thanks.
Teal pelican

2

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

2

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


Why the down vote?
jacoblaw


2

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

Why the downvote?
Kritixi Lithos


2

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


1
i)-*-*-*^_^*-*-*-(^] is much shorter for constructing the top line. Also, Y is equivalent to Vy
DJMcMayhem

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^_^^[
nmjcman101

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
bioweasel

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! |
DJMcMayhem

See? didn't even know that P was a thing. That's awesome though. Thanks!
bioweasel

2

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.

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.