25
\$\begingroup\$

Do you recognize the PPCG logo? it looks like this, when you do an ascii art of it.

+---+
|PCG|
+---+
   v

Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to the PPCG logo.

What You should do

The "Shortened" string will be the string, with all upper case letters and numbers in the input string.(Which would be PPCG when the input string is Programming Puzzles & Code Golf)

The "Box" (

+---+
|   |
+---+
   v

) should fit the Shortened string perfectly.(No bigger or smaller)

Also the v part should be exactly 1 down and 1 left to the down right +.

Then output the box which has the shortened string in it.

Example

Stack Overflow:

+--+
|SO|
+--+
  v

Area 51:

+---+
|A51|
+---+
   v

Rules

You may assume that the input contains at least one digit or upper case letter.

Standard rules apply.

\$\endgroup\$
  • \$\begingroup\$ Very closely related. Also related. \$\endgroup\$ – Martin Ender Jul 8 '16 at 7:02
  • \$\begingroup\$ @MartinEnder Yes, Very closely related, but not duplicate. \$\endgroup\$ – user54200 Jul 8 '16 at 7:03
  • 1
    \$\begingroup\$ @MatthewRoh The purpose of the links is so that the challenges show up in the sidebar, it's not a dupe vote. That said, I personally think removing the unwanted characters and also printing the ^ doesn't add much compared to the second challenge I linked, but I won't cast a dupe hammer on that but let the communitz decide whether they consider it a dupe or not. \$\endgroup\$ – Martin Ender Jul 8 '16 at 7:07
  • 4
    \$\begingroup\$ If it was 99 Bottles Of Beer, it would be 99BOB. \$\endgroup\$ – user54200 Jul 8 '16 at 7:27
  • 1
    \$\begingroup\$ @MatthewRoh its still buggy, let me see if i can get a bf answer after all \$\endgroup\$ – Rohan Jhunjhunwala Jul 29 '16 at 23:35

35 Answers 35

0
\$\begingroup\$

PHP, 112 bytes

<?$s=str_replace('-',' ',$m=ereg_replace('.','-',$n=ereg_replace('[^A-Z0-9]','',$x)));echo"+$m+
|$n|
+$m+
$s",v;
  • PHP<5.4 with register_globals=1, call php-cgi -f <filename> x="<name>";echo""
  • add <pre> after echo" for call in web browser <scriptpath>?x=<name>;
  • for PHP>=5.4: replace $x with $_GET[x] (+6)
    or with $argv[1] to call php <filename> "<name>";echo"" (+6)
  • you may want to add -d error_reporting=0 to cli options

There are times when I love that PHP accepts newlines in constant strings.

  • str_repeat looked like a buddy here, but costs 3 bytes
  • <?=(<assignments>)?"<output>".v:0 costs 1 byte
  • <?=(<assignments>)," <output>",v; does neither cost nor save, but adds a leading blank line to the output
\$\endgroup\$
0
\$\begingroup\$

Japt 2.0 -R, 37 36 bytes

Saved 1 byte thanks to Shaggy

r/\W|\a/
'+²¬qUÊî-
[V'|+U+'|V'viUÊî]

Run it online

\$\endgroup\$
  • 1
    \$\begingroup\$ r/\W|\a/ should save a byte. \$\endgroup\$ – Shaggy Jun 5 '18 at 16:17
0
\$\begingroup\$

SmileBASIC 3, 131 bytes

INPUT N$WHILE""<N$C$=SHIFT(N$)IF@0<C$&&"[">C$||"/"<C$&&":">C$THEN W$=W$+C$
WEND
L=LEN(W$)H$="+"+"-"*L+"+
?H$?"|"+W$+"|
?H$?" "*L+"v
\$\endgroup\$
0
\$\begingroup\$

Kotlin, 129 126 bytes

{s:String->val x=s.filter{it in('A'..'Z')+('0'..'9')}
val h="-".repeat(x.length)
"+$h+\n|$x|\n+$h+\n${" ".repeat(x.length)}v"}

Try it online!

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

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

x=>{x=Replace(x,"[^A-Z0-9]","");Write("{0}{1}\n{0}{2}","+"+"+\n".PadLeft(x.Length+2,'-'),$"|{x}|","v".PadLeft(x.Length+1,' '));}

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy