# This isn't rocket science

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

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

# Excel VBA, 142179175160 155 bytes

Instruction:

Set the worksheet of Excel where cell A1 is input and column C as the output. Set the text alignment in column C to center. Write and run the following code in the Immediate Window:

[C1]="|":[C2]="/_\":T=[A1]&"_":For i=1To Len(T):Cells(i+2,3)="|"&Mid(T,i,1)&"|":Next:Cells(i+2,3)="/__\":Cells(i+3,3)="VvV":[C:C].HorizontalAlignment=-4108

Ungolfed the code:

Sub R()
[C1] = "|"
[C2] = "/_\"
T = [A1]&"_"

For i = 1 To Len(T)
Cells(i + 2, 3) = "|" & Mid(T, i, 1) & "|"
Next

Cells(i + 2, 3) = "/__\"
Cells(i + 3, 3) = "VvV"
[C:C].HorizontalAlignment = -4108   'Set the text alignment in column C to center
End Sub

Output:

Note: The font and the color are just a personal choice.

15 bytes saved due to edc65's suggestion. Thanks.

5 bytes saved due to TaylorScott's suggestion. Thanks.

• Save 15 bytes adding "_" to T. Like this [C1]="|":[C2]="/_\":T=[A1]&" ":For i=1To Len(T):Cells(i+2,3)="|"&Mid(T,i,1)&"|":Next:Cells(i+2,3)="/__\":Cells(i+4,3)="VvV":Columns(3).HorizontalAlignment=-4108 – edc65 Aug 29 '16 at 6:32
• (ok there is an error in my code and it's too late to edit it. But you get the idea) – edc65 Aug 29 '16 at 6:38
• @edc65 I don't get the idea. Your code is exactly the same with mine so what should I edit to save 15 bytes? – Anastasiya-Romanova 秀 Aug 29 '16 at 6:39
• 154 Bytes: [C:C].HorizontalAlignment=-4108:[C1]="|":[C2]="/_\":T=[A1]&"_":For i=1To Len(T):Cells(i+2,3)="|"&Mid(T,i,1)&"|":Next:Cells(i+2,3)="/__\":Cells(i+3,3)="VvV – Taylor Scott Dec 22 '17 at 14:55
• Or you could get it down to 151 bytes, keeping the centering aspect [C:C].HorizontalAlignment=3:[C1]="|":[C2]="/_\":T=[A1]&"_":For i=1To Len(T):Cells(i+2,3)="|"&Mid(T,i,1)&"|":Next:Cells(i+2,3)="/___\":Cells(i+3,3)="VvV – Taylor Scott Jul 12 '18 at 14:37

"  |\n /_\\".say;" |$_|".say for slurp.chomp.comb;" |_|\n/___\\\n VvV".say; • slurp.chomp.comb... Perl is weird. – Mego Aug 26 '16 at 6:31 • SLURP!!! CHOMP!!! COMB!! Here comes the Perl monster! – stommestack Aug 29 '16 at 20:55 # JavaScript (ES6), 54 Straightforward x=> | /_\\ |${[...x+'_'].join|
|}|
/___\\
VvV

Test

f=x=>  |
/_\\
|${[...x+'_'].join| |}| /___\\ VvV function update() { O.textContent=f(I.value) } update() <input id=I value='hello' oninput='update()'><pre id=O></pre> ## Actually, 40 bytes "/___\ VvV",'_o"| |"j'|o" |"+" | /_\ Yes, those newlines are supposed to be there. Try it online! Explanation: Newlines are represented by \n for easier formatting "/___\\n VvV",'_o"|\n |"j'|o" |"+" |\n /_\ "/___\\n VvV" create the bottom of the rocket ,'_o get input, append a "_" (for the last section before the jets) "|\n |"j insert "|\n |" between every pair of characters '|o append "|" " |"+ prepend " |" " |\n /_\ create the nose cone • Your program looks depressingly similar to an exploded rocket. – corsiKa Aug 29 '16 at 23:24 # C, 83, 82 bytes F(char*c){for(puts(" |\n /_\\");*c;printf(" |%c|\n",*c++));puts(" |_|\n/___\\\n VvV");} Test main: int main() { F(""); F("a"); F("|0"); F("\\/\\"); F(" _ _ "); F(" "); F("SPACEY"); } • I worked out my own C solution, and it turned out being exactly yours, character for character. +1 from me. – Cody Aug 26 '16 at 16:31 • On phone and too lazy to SSH, so this is untested, but should work. Saves 2 bytes (if I counted correctly): F(char*c){for(puts(" |\n /_\\");*c;printf(" |%c|\n",*c++),puts(" |_|\n/___\\\n VvV");} – algmyr Aug 27 '16 at 6:10 • @algmyr saves one byte, actually, because the last puts has to be executed only once, not after every printf. But yes, 1 byte saved, yay! – Stefano Sanfilippo Aug 27 '16 at 8:40 • Right. I'll blame that on golfing when I should have been sleeping. – algmyr Aug 27 '16 at 12:12 • Is this not 88 bytes? – gastropner Dec 29 '17 at 14:35 # Python 2, 936662 61 bytes A FGITW. Can probably be heavily golfed. Suggestions welcome. Edit: 27 bytes thanks to Mego. 4 bytes thanks to TheBikingViking. 1 byte thanks to user3030010. Try It Online! lambda x:r""" | /_\ |%s| /___\ VvV"""%"|\n |".join(x+"_") # PHP, 737269 62 bytes | /_\ |<?=join('| |',str_split($argv[1]._))?>|
/___\
VvV

Takes the string to print on the fuselage as the first argument from the command line when the script is called.

Improvements:

1. Saved a byte by replacing \n with a real LF newline in the first argument of join.
2. Saved three more bytes by appending the rocket base with a single underscore to the input
3. Thanks to Ismael Miguel: Saved 7 more bytes by taking advantage of the fact that PHP used to be the "Hypertext preprocessor" so you can output as much text as you want and start the code somewhere in the middle.

Try it online!

This was fun! :-)

Sample calls:

php rocket.php ""
php rocket.php EARTH
php rocket.php "This is a very long rocket"
• – Ismael Miguel Aug 26 '16 at 22:15
• Nice golfing! I totally forgot about that possibility. Thank you! – YetiCGN Aug 26 '16 at 22:22
• You're welcome. Also, I saved 2 bytes on the first line. You had 2 extra trailing spaces on it. That was something I wasn't expecting to find, I must say. – Ismael Miguel Aug 27 '16 at 10:09
• I know, that was really dumb but also really hard to spot. I only noticed once I came up with 64 bytes on your improved version and had to find out why. – YetiCGN Aug 28 '16 at 13:23

# brainfuck, 179 bytes

>-[-[-<]>>+<]>-..[->+>++++<<]>>----.<<++++++++++.>.>>>+[-[--<]>>--]<.[-<+<++>>]<<+.---.<,[<<<.>.>.>.<.>,]<<<.[->>>+<<<]>.>.>>+++.<<.>.>>.<...---.<.<<.>>>------.[-<<<+<+>>>>]<<<.<.

Try it online!

• @user00001 This phrase is used by all Muslims worldwide, not just the terrorist. Do you really think that the terrorists represent all Muslims? – Leaky Nun May 17 '17 at 3:00
• – Leaky Nun May 17 '17 at 8:25

# Ruby, 57 55 bytes

-2 bytes by @ValueInk
-5 bytes by assuming that there is no newline in the input, as suggested by @manatwork. Newline-less input can be provided for example with echo -n, like echo -n hey | ruby rocket.rb.

puts'  |
/_\
|'+gets.chars*'|
|'+'|
|_|
/___\
VvV'
Old version, assumes newline in input:

# Ruby, 62 60 bytes

puts'  |
/_\
|'+gets.chop.chars*'|
|'+'|
|_|
/___\
VvV'
• According to the question owner's comment the input will not contain newline character, so you can remove .chop. – manatwork Aug 26 '16 at 13:11
• @manatwork neat, thanks :) – daniero Aug 26 '16 at 19:54
• If you use single quote strings, you should be able to replace both your \\ with \ . (In single quoted strings, characters aren't escaped, except for \'. – Value Ink Aug 26 '16 at 20:58

# Retina, 44 37 bytes

7 bytes thanks to Martin Ender.

$_ . ¶ |$0|
$¶/___\¶ VvV ^ |¶ /_\ Try it online! • leaves a gap on a row at the bottom :( for "Space, the final frontier." – xQbert Aug 26 '16 at 20:15 • @xQbert Works for me, can you attach a TIO link? – Leaky Nun Aug 27 '16 at 3:36 • odd, it works fine for me now... ah my error had a newline at the end. – xQbert Aug 27 '16 at 16:20 • Retina is the only language I know which adding a trailing newline can completely change the program. – caird coinheringaahing Nov 4 '17 at 16:46 ## Haskell, 58 bytes f s=" |\n /_\\\n |"++((:"|\n |")=<<s)++"_|\n/___\\\n VvV" # Jelly, 37 36 bytes ;”_⁾ |;Ð€ŒB;“/___\“ VvV”“ |“ /_\”;Y Same score as existing entry, but uses a fun new feature - ŒB, the vectorised version of ŒḄ, known as bounce. Bouncing is running through a list to its end and then back x[:-1]+x[::-1] e.g.: bounce("codegolf") == "codegolflogedoc". -1 byte thanks to Dennis (use the vectorised version of bounce) How? ;”_⁾ |;Ð€ŒB;“/___\“ VvV”“ |“ /_\”;Y - argument: a string, S “ |“ /_\” - the top of the rocket [" |", " /_\"] ;”_ - concatenate to make S=S+"_" ⁾ |; - concatenate to make c=" |"+c Ð€ - map over right argument i.e. for c in S ŒB - bounce! With vectorisation c[:-1]+c[::-1] e.g. " |B" -> " |B| " ; - concatenate with “/___\“ VvV” - the bottom of the rocket ["/___\", " VvV"] ; - concatenate the top with everything else Y - join with line feeds Test it on TryItOnline • ŒB is short for ŒḄ€. – Dennis Aug 27 '16 at 3:45 # Pyke, 4037 35 bytes (Updated to work with latest version) \_+2" || "m:"/___\ VvV"+R" | /_\ Try it here! # V, 41, 39 bytes ys$_òlé
òÎá|I |
Hr/$r\YO |GpX2á_o VvV Try it online! Note that for some reason, the online interpreter was producing unexpected results, so I pushed a debug version to the online interpreter that runs a lot slower. It should produce the correct results now. Since this program contains unprintable characters, here is a hexdump: 0000000: 7973 245f f26c e90a f2ce e17c 4920 7c0a ys$_.l.....|I |.
0000010: 4872 2f24 725c 594f 2020 7c1b 4770 5832  Hr/$r\YO |.GpX2 0000020: e15f 6f20 5676 56 ._o VvV • Nice but it doesn't handle the spaces in "Space, the final frontier" quite right. – xQbert Aug 26 '16 at 20:14 # R, 163 bytes v=c();l="\n";for(i in 1:nchar(a<-scan(,"")))v=c(v,paste0(" |",strsplit(a,"")[[1]][i],"|",l,collapse=""));cat(" |",l," /_\\",l,v," |_|",l,"/___\\",l," VvV",sep="") Ungolfed : v=c() #Empty vector l="\n" #Line break for(i in 1:nchar(a<-scan(,""))) #For the number of character of the input v=c(v, paste0(" |",strsplit(a,"")[[1]][i],"|","\n",collapse="")) #This part cut the input into its letters, paste each letter between |'s, #and a line break cat(" |",l," /_\\",l,v," |_|",l,"/___\\",l," VvV",sep="") #Puts everything in the STDOUT, #with spaces where needed I don't really like the fact I had to put some spaces in the last line, but hey ! # PowerShell, 70 bytes " |n /_\n$(([char[]]$a|%{" |$_|"})-join("n"))n |_|n/___\n VvV

Set $a to input. If it has to take input other than a variable it can be piped in: "Hello World"|%{" |n /_\n$(([char[]]$_|%{" |$_|"})-join("n"))n |_|n/___\n VvV "}

Example:

|
/_\
|H|
|e|
|l|
|l|
|o|
| |
|W|
|o|
|r|
|l|
|d|
|_|
/___\
VvV

# Mathematica, 50 bytes

"  |
/_\\
|"<>(#<>"|
|"&/@#)<>"_|
/___\\
VvV"&

Anonymous function. Takes a list of characters as input and returns a string as output.

## PHP, 108100 88 bytes

-8 bytes thanks to business cat

-12 bytes thanks to YetiCGN

echo'  |
/_\\
';foreach(str_split($argv[1])as$c){echo" |$c| ";}echo' |_| /___\\ VvV'; pretty straightforward Ideone • You can save a lot of bytes by using foreach(str_split($a)as$c) instead of the other for loop. Also, you could put the$c directly in the string if you use double quotes: echo" |$c| ...."; – Business Cat Aug 26 '16 at 12:46 • @BusinessCat True, thanks the double quotes wasn't working with the array style thought due to the brackets not being interpreted – Sefa Aug 26 '16 at 13:15 • What about regular expression? function f($a){echo' |.␤ /_\\␤',preg_replace('/./',' |$0|␤',$a),' |_|␤/___\\␤ VvV';} – manatwork Aug 26 '16 at 15:23
• Why even put a function around it? Replacing $a with$argv[1] and running from command line makes it much shorter. – YetiCGN Aug 27 '16 at 7:26
• @manatwork It's probably a valid alternative, but since i don't understand it and it's not the in the same spirit as mine, I will let you post it. – Sefa Aug 29 '16 at 7:23

## C#, 1069780 74 bytes

s=>$@" | /_\ |{string.Join("|\n |",s.ToCharArray())}| |_| /___\ VvV"; I don't have C# 6 to try the above but I believe it will work Saved 7 bytes thanks to Kevin Cruijssen Thanks to manatwork for pointing me in the right direction to save 17 bytes Saved 6 bytes thanks to milk • +1. Btw, trailing whitespaces are optional, so you can change it to: using System.Linq;s=>$(" |\n /_\\\n{string.Join("",s.Select(c=>" |"+c+"|\n"))} |_|\n/___\\\n VvV"); (100 bytes) – Kevin Cruijssen Aug 26 '16 at 12:17
• @KevinCruijssen I was just in the process of updating this after your comments to my previous answer :) Thanks for the help – TheLethalCoder Aug 26 '16 at 12:21
• You can save some characters by using a single string literal inside Select: " |"+c+"|\n"c+"|\n |" together with moving the  | from after {} before it. – manatwork Aug 26 '16 at 13:57
• @manatwork I can't seem to get that to work – TheLethalCoder Aug 26 '16 at 14:02
• New line is 1 byte compared to \n's 2 bytes. So you'll save 5 more bytes by replacing them with new lines. Yes, if you're using Visual Studio then by default new lines will be 2 bytes, but you can open the source file in a hex editor (Visual Studio has one) and delete the carriage return characters. The output will still be the same. – milk Aug 29 '16 at 21:40

## PowerShell v2+, 59 55 bytes

"  |
/_\"
[char[]]"$args"|%{" |$_|"}
" |_|
/___\
VvV"

Try it online!

Abuses the default Write-Output at end of execution to stick a newline between each element, since these are all just literal strings on the pipeline. The only "tricky" bit is a loop through each element of the input "$args" as a char-array to get the body of the rocket. Uses literal newlines as pointed out by ConnorLSW to save some bytes. ### Example PS C:\Tools\Scripts\golfing> .\isnt-rocket-science.ps1 'P_P_C_G' | /_\ |P| |_| |P| |_| |C| |_| |G| |_| /___\ VvV • you can put actual newlines in the string to save 3, the shell and ise execute fine without the \r – colsw May 16 '17 at 9:45 # C, 131 , 121 bytes #define P printf main(){char s[99],*p=s;gets(s);P(" |\n /_\\\n");while(*p)P(" |%c|\n",*p++);P(" |_|\n/___\\\n VvV\n");} • You can remove three characters by moving p=s into the initialization, and using p inside scanf : main(){char s[99],*p=s;scanf("%s",p);P(" |\n /_\\\n");while(*p)P(" |%c|\n",*p++);P(" |_|\n/___\\\n VvV\n");} – Quentin Aug 26 '16 at 12:15 • ok.... i don't know why "scanf("%s", &s)" instead of "scanf("%s", s)" print at end the correct result... at end because scanf not gets spaces i prefer the danger gets()... – RosLuP Aug 26 '16 at 15:55 • Please don't vandalize your posts. Thank you! – NobodyNada Oct 20 '16 at 17:51 # Jelly, 38 37 bytes ;”_“|“|¶”jÐ€“ |¶“/_\¶”;K;“/___\¶ VvV Try it online! Same idea as with my Pyth answer, but this can probably be golfed. # 05AB1E, 504743 37 bytes I'_J" | /_\"svy" |ÿ|"}"/___\ VvV"» Try it online! Saved 9 bytes thanks to Adnan. • String can also accept newlines in 05AB1E :p, like this. – Adnan Aug 26 '16 at 8:42 • @Adnan Nice, thanks! Any idea how to better get around the empty input? – Emigna Aug 26 '16 at 8:45 • I was thinking about an approach with IðJ at the beginning of the program, which also includes the basis of the fuselage. – Adnan Aug 26 '16 at 8:47 • @Adnan Great idea. I tried that with « earlier without much luck. This is much better though. – Emigna Aug 26 '16 at 8:51 • Removing U and replacing X with s also saves a byte :). – Adnan Aug 26 '16 at 8:55 # Kotlin, 68 bytes {""" | /_${it.replace(Regex("."),"\n |$0|")} |_| /___\ VvV"""} Pretty straightforward. Uses multiline string and a regex replacement. This is a lambda with (String)->String type. Test: fun main(args: Array<String>) { val function : (String)->String = {""" | /_${it.replace(Regex("."),"\n |$0|")} |_| /___\ VvV"""} println(function(" _ _ ")) } # Gema, 50 characters \A= |\n\ /_\\\n ?=\ |?|\n \Z=\ |_|\n/___\\\n\ VvV Sample run: bash-4.3$ echo -n gema | gema '\A=  |\n\ /_\\\n;?=\ |?|\n;\Z=\ |_|\n/___\\\n\ VvV'
|
/_\
|g|
|e|
|m|
|a|
|_|
/___\
VvV
• You're missing the  |_| before the base of the rocket I think – TheLethalCoder Aug 26 '16 at 13:40
• Ouch. Dumb miss. Thank you @TheLethalCoder. – manatwork Aug 26 '16 at 13:48
• +1 for introducing me to a new (to me) (non-golfing) language. – Jordan Aug 27 '16 at 1:05

# BASH 84 70

Saved 14 thanks to manatwork

(cat&&echo _)|sed 's~.~ |&|\n~g;1s~^~  |\n /_\\\n~;$s~$~/___\\\n VvV~'

Over half of the bytes are for adding the nose, and engine.

• Why the grep? (cat&&echo _)|sed 's~.~ |&|\n~g;1s~^~ |\n /_\\\n~;$s~$~/___\\\n VvV~'. Actually I see no reason to use cat and echo either. Would be shorter transformed into pure sed solution. – manatwork Aug 26 '16 at 15:00
• With pure sed, you don't get any output if you don't have input – Riley Aug 26 '16 at 15:17
• Doh. You are right. Sorry, I forgot that part of requirement. – manatwork Aug 26 '16 at 15:26
• @manatwork I forgot about it in my first try too. – Riley Aug 26 '16 at 15:27
• For future reference, avoid using <pre><code> tags. Use 4 spaces preceding the code in the future, as this auto-escapes Markdown formatting. I have maintained the current formatting due to the strikethrough, but you can just leave that in edit history as well for those curious to look at it. – Addison Crump Aug 26 '16 at 15:41

# Java 7, 102 99 bytes

String c(char[]i){String r="  |\n /_\\\n |";for(char c:i)r+=c+"|\n |";return r+"_|\n/___\\\n VvV";}

3 bytes saved thanks to @Jules.

Ungolfed & test code:

Try it here.

class M{
static String c(char[] i){
String r = "  |\n /_\\\n |";
for(char c : i){
r += c + "|\n |";
}
return r + "_|\n/___\\\n VvV";
}

public static void main(String[] a){
System.out.println(c("".toCharArray()));
System.out.println();
System.out.println(c("a".toCharArray()));
System.out.println();
System.out.println(c("|0".toCharArray()));
System.out.println();
System.out.println(c("\\/\\".toCharArray()));
System.out.println();
System.out.println(c(" _ _ ".toCharArray()));
System.out.println();
System.out.println(c("    ".toCharArray()));
System.out.println();
System.out.println(c("SPACEY".toCharArray()));
}
}

Output:

|
/_\
|_|
/___\
VvV

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

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

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

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

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

|
/_\
|S|
|P|
|A|
|C|
|E|
|Y|
|_|
/___\
VvV
• Couldn't you make a reference to System.out.println with a shorter name and call that? – Trey Keown Aug 27 '16 at 0:03
• @Trey Keown System.out.println is part of the test code, not the submission. – Captain Ford Aug 27 '16 at 1:24
• You can put " |" onto the end of the 'r' initializer, then inside the loop move it to after the appended string, then you don't need at all in the string appended after the loop. I think this would save you 5 bytes. – Jules Aug 30 '16 at 7:08
• @Jules Thanks! Changed it, and it saves 3 bytes (not sure how you got to a save of 5, though). – Kevin Cruijssen Aug 30 '16 at 7:18

# GolfScript, 61 51 bytes

My first code golf, I hope it is good enough.

"  |
/_\\
"\1/.,{" |"\(\"|
"\}\*" |_|
/___\\
VvV"

### Explanation

"  |\n /_\\\n"   # Push the rocket's head
\                # Swap the head with the user's string
1/               # The string is converted into an array
.,               # Push array length
{" |"\           # Push the rocket's body and swap
(\               # Array's first element cut out
"|\n"\           # Push rocket's body and swap
}\*              # Repeat for array length times
" |_|\n/___\\\n VvV" # Push rocket's bottom

Try it online!

# Vim, 41 39 bytes

Here the <End> is literally the "End" key.

i <End>_:s/./ |&|\r/g
/___\
VvVggxo /_\

Unprintables so:

i <End>_^O:s/./ |&|\r/g
/___\
VvV^[ggxo /_\^[

# Lua, 83, 92 bytes

function f(x)return' |\n /_\\\n'..x:gsub('(.)',' |%1|\n')..' |_|\n/___\\\n VvV'end

print('  |\n /_\\\n'..(arg[1] and arg[1]:gsub('(.)',' |%1|\n') or '')..' |_|\n/___\\\n VvV')
• If I add no input to your answer. It does not work. – nolan Aug 26 '16 at 8:51