60
\$\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\$
  • 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\$ – Hurkyl 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
\$\begingroup\$

Neoscript, 76 bytes

{s|"  |
 /_\\
"+(s as Array):map({e|" |"+e+"|
"}):fuse()+" |_|
/___\\
 VvV"}

{s|...} declare a lambda and as is the casting operator.

\$\endgroup\$
1
\$\begingroup\$

Racket 82 bytes

(display"  |\n /_\\\n")(for((i s))(printf" |~a|~n"i))(display" |_|\n/___\\\n VvV")

Ungolfed:

(define (f s)
  (display "  |\n /_\\\n")
  (for((i s))
    (printf " |~a|~n"i))
  (display" |_|\n/___\\\n VvV"))

Testing:

(f "Racket")

Output: A Rocket by Racket!

  |
 /_\
 |R|
 |a|
 |c|
 |k|
 |e|
 |t|
 |_|
/___\
 VvV
\$\endgroup\$
1
\$\begingroup\$

Python 3, 83 Bytes

s=input("")
print("  | \n /_\\")
for c in s:print(" |"+c+"|")
print("/___\\\n VvV")
\$\endgroup\$
1
\$\begingroup\$

Perl 5, 55+1 (-p flag)=56 bytes

s/(.)/\n |$1|/g;$_="  |  \n /_\\ $_ |_| \n/___\\\n VvV"

Takes string as a single line (with trailing newline) from stdin.

\$\endgroup\$
1
\$\begingroup\$

SOGL V0.12, 27 24 bytes

yQŗ4δ⁾≥‘π0ρ9³‘OΓ,{Ƨ |ΚΓO

Try it Here!

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 27 bytes

S'|ì»"|
/_
ÿ
|_
/__
Vv".∞.c

Try it online!

Explanation

S          # Split input into seperate characters
 '|ì»      # Prepend '|' to each and join by newline
     "|    # Half the rocket, where 'ÿ' is replaced by the processed input
/_
ÿ
|_
/__
Vv"
   .∞.c    # Intersected mirror and centralize
\$\endgroup\$
1
\$\begingroup\$

Excel VBA, 105 103 102 84 82 Bytes

Anonymous VBE Immediate Window function that takes input of type Variant/String from cell [A1] and outputs a rocket to the VBE immdiate window

Golfed:

?"  |":?" /_\":For i=0To[Len(A1)]:?" |"Mid([A1&"_"],i+1,1)"|":Next:?"/___\":?" VvV

Output:

[A1]="NASA.XLSM"
?"  |":?" /_\":For i=0To[Len(A1)]:?" |"Mid([A1&"_"],i+1,1)"|":Next:?"/___\":?" VvV
  |             '  <- Output
 /_\
 |N|
 |A|
 |S|
 |A|
 |.|
 |X|
 |L|
 |S|
 |M|
 |_|
/___\
 VvV
\$\endgroup\$
1
\$\begingroup\$

Google Sheets, 61 60 Bytes

Anonymous worksheet function that takes input from range [A1] and outputs a rocket to the calling cell

="  |
 /_\
 |"&RegExReplace(A1,"(.)","$1|
 |")&"_|
/___\
 VvV

Example Output given [A1]="Google

  |
 /_\
 |G|
 |o|
 |o|
 |g|
 |l|
 |e|
 |_|
/___\
 VvV

-1 byte for removing terminal "

\$\endgroup\$
1
\$\begingroup\$

Jstx, 42 bytes

♀◘ááⁿ▄εá»▀▄84♀☺áⁿE►âD85♀►áⁿ▀ⁿ▄ε»▀▀▀▄▄εá╓÷╓

Explanation

♀◘ááⁿ▄εá»▀▄         # Push literal   |\n /_\
8                   # Print the first stack value, then a newline.
4                   # Enter an iteration block over the first stack value and push the iteration element register at the begining of each loop.
♀☺áⁿ                # Push literal  |
E                   # Push the difference of the second and first stack values.
►â                  # Push literal |
D                   # Push the sum of the second and first stack values.
8                   # Print the first stack value, then a newline.
5                   # End an iteration block.
♀►áⁿ▀ⁿ▄ε»▀▀▀▄▄εá╓÷╓ # Push literal  |_|\n/___\\n VvV

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python 3.7, 79 77 Bytes

o='  | \n /_\\\n'
for c in input()+"_":o+=f' |{c}|\n'
print(o+'/___\\\n VvV')

-2 bytes thanks to Value Ink

\$\endgroup\$
  • \$\begingroup\$ Welcome to PPCG! I think you can save 2 bytes by iterating through input()+"_" so you don't have to manually put in the bottom of the rocket shaft. Try it online! \$\endgroup\$ – Value Ink Jul 27 at 0:35
1
\$\begingroup\$

Oracle SQL, 77 bytes

select'  |
 /_\
'||regexp_replace(x,'(.)',' |\1|
')||' |_|
/___\
 VvV'from t;

It works with an assumption that input string is stored in a table t(x), e.g.

with t(x) as (select 'Earth' from dual)

Test in SQL*Plus

SQL> set pages 0
SQL> with t(x) as (select 'Earth' from dual)
  2  select'  |
  3   /_\
  4  '||regexp_replace(x,'(.)',' |\1|
  5  ')||' |_|
  6  /___\
  7   VvV'from t;
  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
\$\endgroup\$
1
\$\begingroup\$

Pip, 71 69 64 61 bytes

f:"|"u:C95Ps.s.fP" /_\"Fi,#a{Ps.f.a@i.f}P" |_|"P"/___\"" VvV"

Try it online!

[Try it online!][TIO-jyx4p3hj]

f:"|"
u:C95
a:q
Ps.s.f
P" /_\"
F i ,#a{
    Ps.f.a@i.f     make the fuselage
}
P" |_|"
P"/___\"
" VvV"

nothing fancy happening here.

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

JavaScript 63

s=>`  |\n /_\\\n${(s+'_').replace(/./g," |$&|\n")}/___\\\n VvV`

executed using s("test") for example.

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

SpecBAS - 95 bytes

1 input a$: ?"  |"'" /_\"
2 for i=1 to len a$:? " |";a$(i);"|":next i
3 ?" |_|"'"/___\"'" VvV"

The apostrophe moves the cursor down a line, and ? is shorthand for PRINT

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

GNU sed, 53 bytes

1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a\/___\\\n VvV

With GNU sed, you can omit the initial \ for the a command, so it is one byte less:

1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a/___\\\n VvV
\$\endgroup\$
0
\$\begingroup\$

R, 148 bytes

f=function(b){cat("  |\n /_\\\n |",paste(as.character(unlist(strsplit(c(b,"_"),''))),collapse='|\n |'),"|\n/___\\\n VvV",sep="")}
f(commandArgs(T))

If above code is in sample.R file then run from command line

Rscript sample.R "GOKUL"

Output:

  |
 /_\
 |G|
 |O|
 |K|
 |U|
 |L|
 |_|
/___\
 VvV 
\$\endgroup\$
0
\$\begingroup\$

sed, 51 bytes

s/$/_/
s/./ |&|\n/g
s!.*!  |\n /_\\\n&/___\\\n VvV!

Each line from stdin produces a new rocket on stdout.

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

Dart, 110 106 bytes

r(var s){s=s+'_';var o='  |\n /_\\\n',i=0;while(i<s.length)o=o+' |'+s[i++]+'|\n';return o+'/___\\\n VvV';}

Try it out

EDIT: Saved 4 bytes, thanks!

\$\endgroup\$
  • \$\begingroup\$ Do not declare i separately as int, just enumerate it at var. \$\endgroup\$ – manatwork Aug 30 '16 at 16:15
  • \$\begingroup\$ @manatwork What do you mean? How would you not have to declare i? \$\endgroup\$ – stommestack Aug 30 '16 at 16:25
  • \$\begingroup\$ You have, but var is fine for i too: var o=' |\n /_\\\n',i=0. \$\endgroup\$ – manatwork Aug 30 '16 at 16:38
  • \$\begingroup\$ Ah, thanks! I didn't know Dart had that! \$\endgroup\$ – stommestack Aug 30 '16 at 17:06
0
\$\begingroup\$

dc, 55 bytes

Building a rocket with the desck calculator:

?[  |
 /_\
]n[[ |]nn[|
]nz0<R]sRz0!=R[ |_|
/___\
 VvV]p

Because dc interprets input as commands, our string's characters are assumed to be already on the stack and the code is acting more like a function accessing its arguments.

Example run:

me@LCARS:/PPCG$ dc -f rocket_science.dc
[A][S][A][N] #the stack is LIFO, so the arguments (characters) are in reverse order
  |
 /_\
 |N|
 |A|
 |S|
 |A|
 |_|
/___\
 VvV
\$\endgroup\$
0
\$\begingroup\$

RProgN, 59 Bytes

'  |
 /_\' p '.' ' |%1|
' R "
$" '' R p ' |_|
/___\
 VvV' p

Explination

'  |        #
 /_\'       # Build the top of the rocket
p           # Print it.
            # Input is taken implicitly.
'.' ' |%1|  # v
' R         # Replace each character with " |ITSELF|" followed by a newline.
"           # v
$" '' R  # Snip the last newline.
p           # Print the new body.
            #
' |_|       #
/___\       #
 VvV'       # Build the lower segment.
 p          # Print.

Try it Online!

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

Crystal, 89 bytes

x=gets.to_s.chomp;y="  |
 /_\\
";x.each_char{|c|y+=" |#{c}|
"};puts y+" |_|
/___\\
 VvV"

Ungolfed:

input = gets
if !input
  STDERR.puts "Couldn't get input from stdin!"
  exit 1
end
puts <<-'END'
  |
 /_\
END
input.chomp.each_char do |char|
  puts " |#{char}|\n"
end
puts <<-'END'
/___\
 VvV
END

Example usage

Input: Hello, world!

Output:

  |
 /_\
 |H|
 |e|
 |l|
 |l|
 |o|
 |,|
 | |
 |w|
 |o|
 |r|
 |l|
 |d|
 |!|
 |_|
/___\
 VvV
  • Actual newlines instead of \n to save 1 byte per newline
  • String#each_char instead of String#chars.each to save 1 byte
  • Temporary y variable instead of multiple puts calls to save a few bytes
  • As Crystal is statically typed and gets can return nil, I had to find a way to workaround that. not_nil! raises an exception on runtime if the value is nil and otherwise just returns it, however, the Nil class also implements to_s (that returns a 0-length string) which is 4 characters (as opposed to 8). String also implements to_s (just returns itself), so this is a 4 characters shorter way to shut the compiler up.
\$\endgroup\$
0
\$\begingroup\$

Pyth, 44 bytes

js[c2"  |  /_\\"m:" |_|"\_dzc3" |_| /___\ VvV

Try it online!

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

Jq 1.5, 47 bytes

"  |
 /_\\"," |\((./"")[])|"," |_|
/___\\
 VvV"

Expanded

 "  |
  /_\\"             # Head

," |\((./"")[])|"   # Expand |x| with \(interpolation) for each
                    # value from (./"") split of input string by ""
," |_|
 /___\\
  VvV"              # Tail

Try it online!

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

Ruby, 53 bytes

->s{'  |
 /_\
 |'+(s+?_).chars*'|
 |'+'|
/___\
 VvV'}

Try it online!

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

Bean, 51 bytes

xxd-style hexdump:
00000000: 56d8 8100 d7d0 80c3 cf20 5da3 7800 2080  VØ..×Ð.ÃÏ ]£x. .
00000010: 7b56 5881 0158 8102 a0a0 fc8a a0af dfdc  {VX..X..  ü. ¯ßÜ
00000020: 8aa0 7cfc 8aa0 7cfc 8aaf dfdf dfdc 8aa0  . |ü. |ü.¯ßßßÜ. 
00000030: d6f6 56                                  ÖöV

Try it online!

Equivalent JavaScript (ES6), 51 bytes

`  |
 /_\\
 |${[...a,'_'].join`|
 |`}|
/___\\
 VvV`

Explanation

A full program taking the implicit first line of input as a, it pushes the string '_' onto the array to build the last section of the fuselage. This answer is essentially a compilation of edc65's answer into Bean.

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

J, 52 46 45 bytes

2 4|.'___\/','VvV',' |','/_\','|'(,.,.[),&'_'

Try it online!

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

><>, 52 bytes

" ||"i:0(?\$a
__/"a$"_"~/>o<"  |"a" /_\"ar"VvV "a"\_

Try It Online

Adds everything to the stack before printing.

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

SNOBOL4 (CSNOBOL4), 126 bytes

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

Try it online!

Input requires a single trailing newline.

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

Yabasic, 86 bytes

A script that takes input from STDIN and output to the console.

Input""s$
?"  |
 /_\\"
For i=0To Len(s$)?" |",Mid$(s$+"_",i+1,1),"|"Next
?"/___\
 VvV"

Try it online!

\$\endgroup\$
  • \$\begingroup\$ I think you can save three bytes by putting the entire for loop onto one line. \$\endgroup\$ – Jonathan Frech Jul 12 '18 at 14:48
  • \$\begingroup\$ @JonathanFrech You are absolutely right - I can't believe I missed that. \$\endgroup\$ – Taylor Scott Jul 12 '18 at 17:47
0
\$\begingroup\$

Pascal (FPC), 130 bytes

var s:string;c:char;begin writeln('  |'#10' /_\');read(s);for c in s do writeln(' |',c,'|');writeln(' |_|'#10'/___\'#10' VvV')end.

Try it online!

Colouring doesn't work correctly because of \' :)

#10 represents character with ascii code 10 which is a newline.

Basic program flow here: write the top of the rocket, read input, print a row for each character in input (for ... in loop added by FPC), write the bottom of the rocket.

\$\endgroup\$

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.