58
\$\begingroup\$

Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV

Leaderboard

var QUESTION_ID=91182,OVERRIDE_USER=26997;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Related. There may be others which are close enough that this counts as a dupe. \$\endgroup\$ – Peter Taylor Aug 26 '16 at 7:15
  • 2
    \$\begingroup\$ @Sefa Spaces yes. No to other whitespace. As the linked wiki indicates. \$\endgroup\$ – Calvin's Hobbies Aug 26 '16 at 7:28
  • 6
    \$\begingroup\$ D'oh, I saw the title and expected something about brain surgery. :( \$\endgroup\$ – user16488 Aug 26 '16 at 11:22
  • 17
    \$\begingroup\$ And if the bottom points at the sky you will not go to space today. \$\endgroup\$ – AstroDan Aug 26 '16 at 17:59
  • 4
    \$\begingroup\$ "It worked in Kerbal Space Program..." \$\endgroup\$ – Magic Octopus Urn Oct 26 '16 at 17:52

101 Answers 101

1 2 3
4
0
\$\begingroup\$

Perl 5, 46 + 3 (-nlF flag) = 49 bytes

say'  |
 /_\
',(map" |$_|
",@F,_),'/___\
 VvV'

Try it online.

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

05AB1E, 25 bytes

'|„/_©¤IìS'|ì`®¤«„Vv».º.c

Try it online or verify all test cases.

Explanation:

'|      '# Push string "|"
„/_      # Push string "/_"
   ©     # Store it in variable `®` (without popping)
¤        # Get the last character of this string (without popping the string itself): "_"
 Iì      # Prepend the input in front of this "_"
         #  i.e. "Bob" → "Bob_"
   S     # Convert it to a list of characters
         #  → ["B","o","b","_"]
    '|ì '# Prepend a "|" in front of each character
         #  → ["|B","|o","|b","|_"]
       ` # Push all those strings separated to the stack
®        # Push variable `®`: "/_"
 ¤«      # Append it's last character to itself: "/__"
„Vv      # Push string "Vv"
»        # Now join all strings on the stack by newlines
         #  → "|
         #     /_
         #     |B
         #     |o
         #     |b
         #     |_
         #     /__
         #     Vv"
 .º      # Intersected mirror this entire string (towards the right)
         #  → "|
         #     /_\
         #     |B|
         #     |o|
         #     |b|
         #     |_|
         #     /___\
         #     VvV"
   .c    # And then centralize the string (adding leading spaces where necessary)
         #  → "  |
         #      /_\
         #      |B|
         #      |o|
         #      |b|
         #      |_|
         #     /___\
         #      VvV"
         # (after which the result is output implicitly)
\$\endgroup\$
0
\$\begingroup\$

SNOBOL4 (CSNOBOL4), 133 bytes

	OUTPUT('O',6)
	O ='  |'
	O =' /_\'
	I =INPUT
S	I LEN(1) . X REM . I	:F(E)
	O =' |' X '|'	:(S)
E	O =' |_|'
	O ='/___\'
	O =' VvV'
END

Try it online!

Always funny to see the shape of the rocket in these answers.

Only interesting thing here is OUTPUT('O',6), which sets O to be the OUTPUT variable into unit number 6, which is STDOUT.

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

Python 3, 81 bytes

lambda x:"  |\n /_\\\n%s/___\\\n VvV"%''.join([" |%s|\n"%t for t in list(x+'_')])

Try it online!

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

Perl 5, 47 46 + 1 (-n) = 47 bytes

s/./ |$&|
/g;say"  |
 /_\\
$_ |_|
/___\\
 VvV"

Try it online!

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

Stax, 25 bytes

æ¢ïÆn£╗ù♂»Σ√m3,^╝}.Σ8Æ╤º⌡

Run and debug it

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

perl6 - 69

say "  |\n /-\\\n |{@*ARGS.comb.join("|\n |")}|\n |_|\n/___\\\n VvV"
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome! Consider adding an explanation of your program to those who may not understand it. Also consider adding a link to an online interpreter, such as TIO. Code-only answers are usually automatically flagged as low-quality. \$\endgroup\$ – mbomb007 Aug 2 '19 at 18:12
0
\$\begingroup\$

GolfScript, 53 bytes

"  |\n /_\\"n@0$1/\;{" |"\"|\n"}/" |_|\n/___\\\n VvV"

Try it online!

"  |\n /_\\"n        ascii art
@                    rotate so input is on top
0$1/                 split input into elements of size 1
\;                   swap top elements, pop top (input)
{" |"\"|\n"}/        now the top element is the input array so for each we push the left pipe, swap, then push the right pipe
" |_|\n/___\\\n VvV" ascii art
\$\endgroup\$
0
\$\begingroup\$

33, 75 69 bytes

-6 bytes because I remembered \n is a thing.

"  |\n /_\\"pi1bzst' | |'j[2ktNpNitclz1aztstcjz]" |_|\n/___\\\n VvV"p

Try it online hopefully coming soon

Explanation:

"  |\n /_\\"pi                     | Print the first part of the rocket
-----------------------------------|
1bzs                               | Get the first command-line argument
            j[       clz1aztstcjz] | For each character in it
     t' | |'  2k                   | - Put it in the fuselage "| |"
                NpNi               | - If it is not null, print it (Null checking is due to the way loops work in 33)
-----------------------------------|
" |_|\n/___\\\n VvV"p              | Print the bottom of the rocket
\$\endgroup\$
0
\$\begingroup\$

Python 3, 86 bytes

code-golf:

n=input();print('  |\n / \ ')
for l in n:print(' |'+l+'|')
print(' |_|\n/___\ \n VvV')

normal:

n = input()
print('  |')
print(' / \')

for l in n:
    print(' |' + l + '|')

print(' |_|')
print('/___\')
print(' VvV')
```
\$\endgroup\$
0
\$\begingroup\$

C#, 159 bytes

public class P{public static void Main(string[]a){var f="";foreach (char c in a[0]){f+=" |"+c+"|\n";}System.Console.Write(@"  |
 /_\
"+f+@" |_|
/___\
 VvV");}}

Try Online

\$\endgroup\$
1
  • \$\begingroup\$ Suggest foreach(var c in a[0])f+=" |"+c+"|\n"; instead of foreach (char c in a[0]){f+=" |"+c+"|\n";} \$\endgroup\$ – ceilingcat Aug 15 '20 at 16:55
1 2 3
4

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.