ユーザーへの挨拶


16

実行時に以下のテキストを表示するプログラムを作成します。

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

関数または言語を使用してこれに答え、楽しんでください。最短のコードが勝つ


3
通常どおり、関数からこれを代わりに返すことはできますか?
— スティーブン

6
先頭/末尾の改行は許可されていますか?
— グリフォン-モニカの復活

回答:


6

Japt、41 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
— Mr. Xcoder

OK。その下票を削除しました。
— juniorRubyist

ありがとう。元々は出力制限のハードコーディングについて言及していたと思いますが、それはkolmogorov-complexityのために許可されています。特に効率的ではありません。
— BradC


8

C(gcc)、78 75バイト

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

オンラインでお試しください!


試してみてください、バイト数もかなり少ないです!
— Amurt4l

私はそれを持っている最低はこれまでに66のバイトをある
— Amurt4l

末尾に改行を含む71バイト(75なし):#define P puts(")-*-*-*^_^*-*-*-(") f(){P;puts("| Welcome User! |");P;}
— Steadybox

2
@ Amurt4l必要に応じて、かなりの数の回答を得たので、自分の回答も投稿できます。)
— スティーブン

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
この言語<S>が</ S>は、私たちが言語を少し変更するだけので@Dennisが持っていること、それらを変更すべきだと思うことを、「ルール」のように虐待のように感じている
— スティーブン・

@StephenS TBH、私は同意します。ただし、ありがたいことにkolmogorovの複雑さのために最適化された言語(Jelly、05AB1E、V、SOGL、他のいくつか)は、通常、安っぽく感じずにそれを打ち負かすことができます。
— DJMcMayhem

11
@StephenS Bubblegumを使用して課題を解決するのが最適な場合、それは言語の問題ではなく、課題の問題です。規則を弁護士化する代わりに、より興味深い課題を書きます。
— アンデルスカセオルグ

6

05AB1E、31 29 26バイト

Emignaのおかげで-3バイト

")-*-*-*^_".∞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
.∞代わりに行うことができますû¨'(«
— エミグナ

これは何とか存在しなければならないことを知っていました!おかげで男
— ダトボイ

気にしないで、私が投稿したものは同等の笑でした。
— 魔法のタコUr

5

Python 3、62バイト

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

関数である必要があります。
— juniorRubyist


3
しかし、それはスニペットではありません。完全なプログラムです。
— 完全に人間

2
いいえ、機能である必要はありません。もう一度お読みください
— マウロBaraldi

2
@juniorRubyist質問の1行目は述べていますCreate a program
— dzaima

5

JavaScript、56バイト

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

JavaScript(ES6)、50 48バイト(関数)

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

-Rick Hitckcockのおかげで2バイト


なんでalert?関数を使用して数バイトを保存します。
— シャギー

@Shaggy私はちょうどそれを編集し、それを知っているが、現在はOPは表示が言うと、まだ私のコメントに応答しなかった
— スティーブン


4
@juniorRubyistでは、通常、完全なプログラムまたは関数を許可しています。OPは、値を表示する代わりに返す関数が許可されることを指定していなかったため、2番目の2つのエントリは許可されない可能性があります。ただし、完全なプログラムは(ほぼ)常に許可されており、JavaScriptには定型文は必要ありません。my alertを.jsファイルにコピーしてブラウザーで実行すると、実行されます。
— スティーブン

_=>(s=")-*-*-*^_^*-*-*-(")+\ n |で2バイト節約 ようこそユーザー!| \ n+s
— リックヒッチコック

4

C、75バイト

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

このような70バイト。m=")-*-*-*^_^*-*-*-(";main(){printf("%s\n| Welcome User! |\n%s",m,m);}
— cleblanc



4

MATLAB /オクターブ、53バイト

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

なんでMATLAB / Python?これは間違いなく有効なpythonではありません。
— DJMcMayhem

@DJMcMayhemすみません、オクターブを意味しました。タイプミスに気づいてくれてありがとう。1日中Pythonの質問に答えていたので、脳に小さな不具合がありました:)
— rayryeng-モニカの復活

省略した場合、dispMatlabはリードを表示しans = \nます。
— クローリー

@Crowley disp正確な出力に適合しないため、そこが必要な理由です。
— rayryeng-モニカを復活させる

場合はans = 禁止されていないあなたは6つのバイトを保存することができます。
— クローリー

4

Perl 5、49バイト

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

オンラインでお試しください!

$\それぞれの後に暗黙的に印刷される事実を使用しますprint。


どうsay?
— シンバク

1
@simbabque私はこのコンセンサスに従う傾向があります。さらに、すべてprintを置き換えることsayは、ゴルフのポイントが私の意見にある場所ではありません。しかし、私は使用をやめるためのいかなる改革運動もしていませんsay。私は誰もが好きなようにし、誰もが幸せです:)
— ダダ

4

炭、32 30バイト

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

オンラインでお試しください!リンクは、コードの詳細バージョンです。説明:

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

出力の左上部分の鏡像を印刷します。

‖B¬             ReflectButterfly(:¬);

下と左に反射して、上下の線と中央の線の左を作成します。

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

中央の行を修正します。


(なぜダウン票ですか?)
— ニール

2
どうやら誰かがこの課題の多くの答えを否定しているようですが、私の投稿も影響を受けたものの1つです。
— クリティキシリソス

3

Mathematica、52バイト

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

3

Golang、82バイト

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

オンラインでお試しください!


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.

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.