Saluto l'utente


16

Crea un programma che quando viene eseguito visualizza il testo seguente:

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

Usa qualsiasi funzione o lingua per rispondere a questo, divertiti. Il codice più corto vince


3
Possiamo in alternativa restituirlo da una funzione, come al solito?
Stephen,

6
Sono consentite le nuove righe iniziali / finali?
Gryphon,

Risposte:


6

Japt , 41 39 byte

Salvato 2 byte grazie a @Shaggy

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

Spiegazione:

[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

Provalo online!




12

T-SQL, 60 byte

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

SQL consente di dividere i valori letterali delle stringhe su righe, quindi vengono conteggiati i ritorni.

Lavorando su una soluzione procedurale, ma dubito che ne troverò uno sotto i 60 anni.

Nuova modifica : trovato un semplice REPLACEche lega la banale soluzione:

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

Si scopre che REPLACE farà una conversione implicita di un numero in una stringa, quindi questo mi permette di salvare 2 caratteri eliminando le virgolette attorno al mio carattere sostitutivo.

Cercare di inserirlo in una variabile è troppo lungo, a causa del sovraccarico dei DECLARE(69 byte):

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


8
Questa risposta è completamente a posto @juniorRubyist
Mr. Xcoder,

Ok. Ho rimosso quel voto negativo.
juniorRubyist,

Grazie. Pensavo che in origine ti riferissi alla codifica hard della limitazione dell'output , ma questo è permesso per la complessità di kolmogorov. Solo non particolarmente efficiente.
BradC,

9

Python 2.7, 55 byte

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

Abbastanza semplice. Include le nuove righe principali e finali.


13
Non deve essere una funzione.
totalmente umano il

8

C (gcc) , 78 75 byte

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

Provalo online!


Bel tentativo, anche una quantità piuttosto bassa di byte!
Amurt4l,

Il più basso a cui sono arrivato è 66 byte finora
Amurt4l


2
@Amurt4l, se lo desideri, dato che hai ricevuto alcune risposte, puoi pubblicare anche la tua risposta :)
Stephen

6

Bubblegum , 43 byte

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

Provalo online!


3
Questa lingua <s> è </s> sembra un tale abuso delle "regole", che penso che dovremmo cambiarle solo in modo che @Dennis dovrà cambiare un po 'la lingua
Stephen

@StephenS TBH, sono d'accordo. Tuttavia, per fortuna, i linguaggi ottimizzati per la complessità del kolmogorov (Jelly, 05AB1E, V, SOGL, alcuni altri) possono ancora batterlo senza sentirsi a buon mercato.
DJMcMayhem

11
@StephenS Se una sfida è risolta al meglio con Bubblegum, è colpa della sfida, non del linguaggio. Invece di legiferare sulle regole, scrivi sfide più interessanti.
Anders Kaseorg,

6

05AB1E , 31 29 26 byte

-3 byte grazie a Emigna

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

Provalo online!

Spiegazione

")-*-*-*^_".∞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
Si potrebbe fare .∞invece diû¨'(«
Emigna il

Sapevo che questo doveva esistere in qualche modo! Grazie amico
Datboi,

Non importa, quello che ho pubblicato era equivalente lol.
Magic Octopus Urn,

So che è passato un po 'di tempo, ma puoi salvare un byte cambiando ")-*-*-*^_"in ')„-*Є^_J. :)
Kevin Cruijssen il

5

Python 3, 62 byte

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

Deve essere una funzione.
juniorRubyist,


3
Ma non è un frammento. È un programma completo.
totalmente umano il

2
No, non deve essere una funzione. Leggi di nuovo: usa qualsiasi funzione o lingua per rispondere a questa domanda.
Mauro Baraldi,

2
@juniorRubyist La prima riga della domanda diceCreate a program
dzaima,

5

JavaScript, 56 byte

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

JavaScript (ES6), 50 48 byte (funzione)

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

-2 byte grazie a Rick Hitckcock


Perché alert? Salva qualche byte usando una funzione.
Shaggy,

@Shaggy Lo so, l'ho appena modificato, ma attualmente OP dice display, e non ha ancora risposto al mio commento
Stephen,


4
@juniorRubyist di solito consentiamo un programma completo o una funzione. OP non ha specificato che le funzioni che hanno restituito il valore invece di visualizzarlo erano consentite, quindi le mie seconde due voci potrebbero non essere consentite. Tuttavia, i programmi completi sono (quasi) sempre consentiti e JavaScript non necessita di boilerplate. Copia my alertin un .jsfile ed eseguilo nel tuo browser, verrà eseguito.
Stephen,

Salva 2 byte con _=>(s=")-*-*-*^_^*-*-*-(")+\ n | Benvenuto utente! | \ n+s
Rick Hitchcock,

4

C, 75 byte

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

70 byte come questo; m=")-*-*-*^_^*-*-*-(";main(){printf("%s\n| Welcome User! |\n%s",m,m);}
Cleblanc,



4

MATLAB / Octave, 53 bytes

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

Why MATLAB / Python? This is definitely not valid python.
DJMcMayhem

@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 :)
rayryeng - Reinstate Monica

If you ommit disp Matlab will show leading ans = \n.
Crowley

@Crowley That's why you need the disp there as it won't conform to the exact output.
rayryeng - Reinstate Monica

If the ans = is not disallowed you can save 6 bytes.
Crowley

4

Perl 5, 49 bytes

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

Try it online!

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

bash, 52 bytes

f=")-*-*-*^_^*-*-*-("
echo "$f
| Welcome User! |
$f"

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.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.