This isn't rocket science

59

14

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>

Calvin's Hobbies

Posted 2016-08-26T06:13:09.950

Reputation: 84 000

1Related. There may be others which are close enough that this counts as a dupe. – Peter Taylor – 2016-08-26T07:15:50.040

Are withespace characters (newline, tab and space) considered as printable ASCII? if yes should we take them into account and how (mainly for tab and newline) – Sefa – 2016-08-26T07:24:33.263

2

@Sefa Spaces yes. No to other whitespace. As the linked wiki indicates.

– Calvin's Hobbies – 2016-08-26T07:28:16.493

6D'oh, I saw the title and expected something about brain surgery. :( – None – 2016-08-26T11:22:38.743

17And if the bottom points at the sky you will not go to space today. – AstroDan – 2016-08-26T17:59:22.550

1It's not rocket appliances! – Ryguy – 2016-08-29T21:13:17.403

4"It worked in Kerbal Space Program..." – Magic Octopus Urn – 2016-10-26T17:52:10.953

Could I enter with PETSCII characters rather than ASCII? See -> https://sta.c64.org/cbm64pet.html

– Shaun Bebbers – 2020-02-20T09:48:56.280

Answers

55

Excel VBA, 142 179 175 160 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:

enter image description here

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.

Anastasiya-Romanova 秀

Posted 2016-08-26T06:13:09.950

Reputation: 1 673

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 – 2016-08-29T06:32:32.190

(ok there is an error in my code and it's too late to edit it. But you get the idea) – edc65 – 2016-08-29T06:38:44.430

@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 秀 – 2016-08-29T06:39:45.763

I edited it some times, look at it again – edc65 – 2016-08-29T06:41:07.997

@edc65 Ahh, I get it. Very clever. Thank you so much :) – Anastasiya-Romanova 秀 – 2016-08-29T07:15:49.793

1154 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 – 2017-12-22T14:55:26.657

@Anastasiya-Romanova秀 just in case you did not know, if you end your immediate window function with an unclosed string, VBA does not throw an error so if you move :Cells(i+2,3)="/_‌​_\" or :Cells(i+3,3)="Vv‌​V" to the end you can drop the terminal " for -1 byte :) – Taylor Scott – 2017-12-26T22:55:31.790

Huh, I think you are missing a _ in the Cells(i+2,3) call - Anyways, an alternate approach, also 154 bytes: [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].Font.Name="Courier – Taylor Scott – 2017-12-26T23:11:08.850

1Or 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 – 2018-07-12T14:37:42.230

It seems as though this just centers the text rather than outputting a space before the |<insert char here>| – MilkyWay90 – 2019-03-29T23:08:40.357

30

Perl 6, 75 bytes

"  |\n /_\\".say;" |$_|".say for slurp.chomp.comb;" |_|\n/___\\\n VvV".say;

bb94

Posted 2016-08-26T06:13:09.950

Reputation: 1 831

101slurp.chomp.comb... Perl is weird. – Mego – 2016-08-26T06:31:22.240

14SLURP!!! CHOMP!!! COMB!! Here comes the Perl monster! – stommestack – 2016-08-29T20:55:07.180

Note that by using a function and concatanation you can cut out a lot: {[~] " |\n /_\\\n",|(" |$_|\n"for $_.comb)," |_|\n/___\\\n VvV"} 65 bytes – user0721090601 – 2019-07-27T21:38:15.673

But you can go even lower by borrowing from JS's: https://tio.run/##K0gtyjH7n1upoJamYKvwX9cuprhaSUGhhktBPz4mhkuhWkOpRiW@hkspLb9IoVgvOT83SbNWoQYooh8fD1YRVhamVPvfmqs4EWSIhlJJanFJZl66kqb1fwA

– user0721090601 – 2019-07-27T21:45:58.230

22

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>

edc65

Posted 2016-08-26T06:13:09.950

Reputation: 31 086

16

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

Mego

Posted 2016-08-26T06:13:09.950

Reputation: 32 998

12Your program looks depressingly similar to an exploded rocket. – corsiKa – 2016-08-29T23:24:25.523

15

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");
}

Stefano Sanfilippo

Posted 2016-08-26T06:13:09.950

Reputation: 1 059

7I worked out my own C solution, and it turned out being exactly yours, character for character. +1 from me. – Cody – 2016-08-26T16:31:30.260

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 – 2016-08-27T06:10:04.357

@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 – 2016-08-27T08:40:01.493

Right. I'll blame that on golfing when I should have been sleeping. – algmyr – 2016-08-27T12:12:02.507

Is this not 88 bytes? – gastropner – 2017-12-29T14:35:32.087

10

Python 2, 93 66 62 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+"_")

Sherlock9

Posted 2016-08-26T06:13:09.950

Reputation: 11 664

9

PHP, 73 72 69 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"

YetiCGN

Posted 2016-08-26T06:13:09.950

Reputation: 941

62 bytes: http://sandbox.onlinephpfunctions.com/code/5c640244e19b43a44c364a971ea796f277e4dbf4

– Ismael Miguel – 2016-08-26T22:15:50.197

Nice golfing! I totally forgot about that possibility. Thank you! – YetiCGN – 2016-08-26T22:22:13.153

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 – 2016-08-27T10:09:07.757

1I 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 – 2016-08-28T13:23:13.463

8

Haskell, 58 bytes

f s="  |\n /_\\\n |"++((:"|\n |")=<<s)++"_|\n/___\\\n VvV"

xnor

Posted 2016-08-26T06:13:09.950

Reputation: 115 687

8

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'

daniero

Posted 2016-08-26T06:13:09.950

Reputation: 17 193

According to the question owner's comment the input will not contain newline character, so you can remove .chop.

– manatwork – 2016-08-26T13:11:13.563

@manatwork neat, thanks :) – daniero – 2016-08-26T19:54:46.533

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 – 2016-08-26T20:58:40.543

8

brainfuck, 179 bytes

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

Try it online!

Leaky Nun

Posted 2016-08-26T06:13:09.950

Reputation: 45 011

@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 – 2017-05-17T03:00:16.047

7

Retina, 44 37 bytes

7 bytes thanks to Martin Ender.

$
_
.
¶ |$0|
$
¶/___\¶ VvV
^
  |¶ /_\

Try it online!

Leaky Nun

Posted 2016-08-26T06:13:09.950

Reputation: 45 011

leaves a gap on a row at the bottom :( for "Space, the final frontier." – xQbert – 2016-08-26T20:15:50.593

@xQbert Works for me, can you attach a TIO link? – Leaky Nun – 2016-08-27T03:36:59.190

odd, it works fine for me now... ah my error had a newline at the end. – xQbert – 2016-08-27T16:20:13.173

Retina is the only language I know which adding a trailing newline can completely change the program. – caird coinheringaahing – 2017-11-04T16:46:58.820

6

Pyke, 40 37 35 bytes

(Updated to work with latest version)

\_+2" ||
"m:"/___\
 VvV"+R"  |
 /_\

Try it here!

Blue

Posted 2016-08-26T06:13:09.950

Reputation: 26 661

6

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

Jonathan Allan

Posted 2016-08-26T06:13:09.950

Reputation: 67 804

2ŒB is short for ŒḄ€. – Dennis – 2016-08-27T03:45:03.897

5

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

James

Posted 2016-08-26T06:13:09.950

Reputation: 54 537

Nice but it doesn't handle the spaces in "Space, the final frontier" quite right. – xQbert – 2016-08-26T20:14:12.740

5

PowerShell v2+, 59 55 51 bytes

"  |
 /_\"
$args|% t*y|%{" |$_|"}
" |_|
/___\
 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.
-4 more bytes thanks to Veskah.

AdmBorkBork

Posted 2016-08-26T06:13:09.950

Reputation: 41 581

you can put actual newlines in the string to save 3, the shell and ise execute fine without the \r – colsw – 2017-05-16T09:45:29.390

t*y trick to save 4 bytes – Veskah – 2019-07-26T13:58:23.580

5

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 !

Frédéric

Posted 2016-08-26T06:13:09.950

Reputation: 2 059

4

PHP, 108 100 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

Sefa

Posted 2016-08-26T06:13:09.950

Reputation: 582

1You 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 – 2016-08-26T12:46:38.410

@BusinessCat True, thanks the double quotes wasn't working with the array style thought due to the brackets not being interpreted – Sefa – 2016-08-26T13:15:35.437

What about regular expression? function f($a){echo' |. /_\\ ',preg_replace('/./',' |$0| ',$a),' |_| /___\\ VvV';} – manatwork – 2016-08-26T15:23:43.793

1Why even put a function around it? Replacing $a with $argv[1] and running from command line makes it much shorter. – YetiCGN – 2016-08-27T07:26:22.347

@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 – 2016-08-29T07:23:57.037

4

C#, 106 97 80 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

TheLethalCoder

Posted 2016-08-26T06:13:09.950

Reputation: 6 930

+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 – 2016-08-26T12:17:44.230

1@KevinCruijssen I was just in the process of updating this after your comments to my previous answer :) Thanks for the help – TheLethalCoder – 2016-08-26T12:21:17.223

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 – 2016-08-26T13:57:10.210

@manatwork I can't seem to get that to work – TheLethalCoder – 2016-08-26T14:02:06.843

@manatwork Doesn't matter, got it to work and saved even more bytes – TheLethalCoder – 2016-08-26T14:06:44.920

-1 byte with LINQ to use s.Cast<char>() instead of s.ToCharArray(). More importantly, -6 bytes by using verbatim strings (@ fyi- after the $ for interpolated verbatim string) to replace \n with newlines and \\ with \, plus then you can even see the rocket in the source. – milk – 2016-08-26T22:55:15.740

@milk adding linq means I have to add using System.Linq which is more bytes. Replacing new lines with new lines is still the same count but @ can save me one byte anyway thanks – TheLethalCoder – 2016-08-28T09:45:01.370

1New 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 – 2016-08-29T21:40:32.740

@milk Ahhh okay me being daft, thanks – TheLethalCoder – 2016-08-30T07:56:23.137

If u add the using 'using static System.String;' you can write Join instead of string.Join. C# 6.0 for the win. – CSharpie – 2016-12-13T20:26:41.283

4

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");}

RosLuP

Posted 2016-08-26T06:13:09.950

Reputation: 3 036

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 – 2016-08-26T12:15:54.427

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 – 2016-08-26T15:55:28.593

2Please don't vandalize your posts. Thank you! – NobodyNada - Reinstate Monica – 2016-10-20T17:51:56.187

1114 bytes – ceilingcat – 2019-11-15T23:32:00.810

@ceilingcat If was possible the definition [#define P printf(" |] it would be less than 114... – RosLuP – 2019-11-16T14:09:45.613

4

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 

Chirishman

Posted 2016-08-26T06:13:09.950

Reputation: 389

4

Mathematica, 50 bytes

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

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

LegionMammal978

Posted 2016-08-26T06:13:09.950

Reputation: 15 731

3

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 /_\^[

nmjcman101

Posted 2016-08-26T06:13:09.950

Reputation: 3 274

3

Charcoal, 22 bytes

↷¦|_θ__←v↖V→/↑_↑⊕Lθ/‖B

Try it online!

Needs trailing newline in input, due to how Charcoal input works.

Erik the Outgolfer

Posted 2016-08-26T06:13:09.950

Reputation: 38 134

3

V, 47 46 39 37 35 bytes

A_Ó./ |&|\r
a/___\
 VvVHO  |
 /_\

Try it online!

This is my first time trying to golf something. There is probably room for improvement since I don't know V, only vim.

Hexdump:

00000000: 415f 1bf3 2e2f 207c 267c 5c72 2f67 0a61  A_.../ |&|\r/g.a
00000010: 2f5f 5f5f 5c0a 2056 7656 1b48 4f20 207c  /___\. VvV.HO  |
00000020: 0a20 2f5f 5c                             . /_\

oktupol

Posted 2016-08-26T06:13:09.950

Reputation: 697

3Welcome to PPCG! – Martin Ender – 2017-12-22T14:37:34.037

3

Java 10, 102 99 81 bytes

a->{var r="  |\n /_\\\n |";for(var c:a)r+=c+"|\n |";return r+"_|\n/___\\\n VvV";}

3 bytes saved thanks to @Jules.

Try it online.

Explanation:

a->{                      // Method with character-array parameter and String return-type
  var r="  |\n /_\\\n |"; //  Result-String, starting with the top part:
                          //   |
                          //  /_\
                          //  |
  for(var c:a)            //  Loop over each character in the input-array:
    r+=c                  //   Append the character to the result-String,
        +"|\n |";         //   with trailing:
                          //    |
                          //  |
  return r                //  Return the result-String,
   +"_|\n/___\\\n VvV";}  //  appended with bottom part:
                          //   _|
                          // /___\
                          //  VvV

Kevin Cruijssen

Posted 2016-08-26T06:13:09.950

Reputation: 67 575

Couldn't you make a reference to System.out.println with a shorter name and call that? – Trey Keown – 2016-08-27T00:03:51.327

1@Trey Keown System.out.println is part of the test code, not the submission. – Captain Ford – 2016-08-27T01:24:54.530

1You 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 – 2016-08-30T07:08:55.730

@Jules Thanks! Changed it, and it saves 3 bytes (not sure how you got to a save of 5, though). – Kevin Cruijssen – 2016-08-30T07:18:27.423

3

05AB1E, 50 47 43 37 bytes

I'_J"  |
 /_\"svy" |ÿ|"}"/___\
 VvV"»

Try it online!

Saved 9 bytes thanks to Adnan.

Emigna

Posted 2016-08-26T06:13:09.950

Reputation: 50 798

String can also accept newlines in 05AB1E :p, like this.

– Adnan – 2016-08-26T08:42:12.173

@Adnan Nice, thanks! Any idea how to better get around the empty input? – Emigna – 2016-08-26T08:45:33.440

I was thinking about an approach with IðJ at the beginning of the program, which also includes the basis of the fuselage. – Adnan – 2016-08-26T08:47:56.413

@Adnan Great idea. I tried that with « earlier without much luck. This is much better though. – Emigna – 2016-08-26T08:51:45.343

Removing U and replacing X with s also saves a byte :). – Adnan – 2016-08-26T08:55:46.303

@Adnan: yep, was just looking at that. Thanks! – Emigna – 2016-08-26T09:00:21.290

3

Jelly, 38 37 bytes

;”_“|“|¶”jЀ“  |¶“/_\¶”;K;“/___\¶ VvV

Try it online!

Same idea as with my Pyth answer, but this can probably be golfed.

PurkkaKoodari

Posted 2016-08-26T06:13:09.950

Reputation: 16 699

3

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')

nolan

Posted 2016-08-26T06:13:09.950

Reputation: 31

If I add no input to your answer. It does not work. – nolan – 2016-08-26T08:51:30.543

3

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(" _ _ "))
}

JustACluelessNewbie

Posted 2016-08-26T06:13:09.950

Reputation: 161

3

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

manatwork

Posted 2016-08-26T06:13:09.950

Reputation: 17 865

3You're missing the |_| before the base of the rocket I think – TheLethalCoder – 2016-08-26T13:40:57.813

Ouch. Dumb miss. Thank you @TheLethalCoder. – manatwork – 2016-08-26T13:48:56.353

1+1 for introducing me to a new (to me) (non-golfing) language. – Jordan – 2016-08-27T01:05:13.613

3

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.

Riley

Posted 2016-08-26T06:13:09.950

Reputation: 11 345

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 – 2016-08-26T15:00:16.637

With pure sed, you don't get any output if you don't have input – Riley – 2016-08-26T15:17:22.470

Doh. You are right. Sorry, I forgot that part of requirement. – manatwork – 2016-08-26T15:26:46.843

@manatwork I forgot about it in my first try too. – Riley – 2016-08-26T15:27:59.720

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 – 2016-08-26T15:41:22.373

@Syxer Thanks! I wasn't sure what the standard was in regards to striking or just removing. – Riley – 2016-08-26T15:43:21.413

Additionally if you keep the solution alone in its code block, Code Golf UserScript Enhancement Pack and similar scripts can insert correct length beside it. For example saying your code has 71 characters – you forgot to remove the \ added by Syxer to avoid _ being interpreted as italic markdown.

– manatwork – 2016-08-26T15:51:39.773

3

GNU sed, 54 49 48 bytes

This was my first answer to a challenge on this site. The solution is simple, mainly printing, so I spent some time making sure that it can't be golfed anymore.

s:.:\n |&|:g
s::  |& /_\\&:
a\ |_|\n/___\\\n VvV

Try it online!

Fast forward half a year later, I rewrote the script, used a trick for good measure and golfed it down to 1 byte shorter. Now that's progress!

Explanation: the pattern space at each step is mentioned for clarity, given the input example "GO"

s:.:\n |&|:g
   # turn each input char into a section of the rocket (\n |G|\n |O|)
s::  |& /_\\&:
   # 's::' is a trick; the search part is actually the one from the previous 's'
   #command, i.e. a char. Only the first char, '\n', the modifier 'g' is not
   #inherited. The replace part is the head of the rocket. (  |\n /_\\n |G|\n |O|)
a\ |_|\n/___\\\n VvV
   # append the tail of the rocket, plus implicit printing at the end

  |
 /_\
 |G|
 |O|
 |_|
/___\
 VvV

seshoumara

Posted 2016-08-26T06:13:09.950

Reputation: 2 878

3

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!

FedeWar

Posted 2016-08-26T06:13:09.950

Reputation: 271

2

CJam, 38 bytes

"  |
 /_\
 |"q'_+"|
 |"*"|
/___\
 VvV"

Try it online!

Explanation

Nothing fancy, pretty straightforward.

"  |\n /_\\n |"                              Push the top of the rocket
               q'_+                          Push the input and append an underscore
                   "|\n |"*                  Join the characters of the input with the sides
                           "|\n/___\\n VvV"  Push the bottom of the rocket

Business Cat

Posted 2016-08-26T06:13:09.950

Reputation: 8 927

2

Common Lisp, 85 74 bytes

(lambda(s)(format t"  |
 /_\\
~{ |~a|
~} |_|
/___\\
 VvV"(coerce s'list)))

Try it online!(I added some bytes to call this anonymous function)

For changing part we take input as string.

~{ |~a|         ;we loop through all characters of string
    ~}          ;printing characters from list
(coerce s'list) ;string is converted into list of characters later used by above loop

user65167

Posted 2016-08-26T06:13:09.950

Reputation:

2

Keg, 52 characters

?(\|'\| \
)\\\_\/ \
\|  ^\
 \|\_\|\
\/\_\_\_\\\
 VvV

Only tricky point is that Keg has no strings, the input is pushed to stack character by character. So the processing order is: read input (?) and turn it into middle section, append top section reversed, reverse them all (^), append bottom section.

(Note that the interpreter (TIO implementation?) does not support absolutely no input. Empty input is specified as single newline, which will not be processed anyway.)

Try it online!

manatwork

Posted 2016-08-26T06:13:09.950

Reputation: 17 865

2

Pyth, 38 bytes

j++"  |
 /_\\"jR_B" |"+Q\_"/___\\
 VvV

Try it online. Test suite.

PurkkaKoodari

Posted 2016-08-26T06:13:09.950

Reputation: 16 699

Also 38 bytes: %." |¼v¤<½ózÓa9Êh"jXL2" ||"+z\_

– hakr14 – 2018-07-15T18:54:40.577

2

Scala, 97 94 77 bytes

print("  |\n /_\\\n"+args(0).map{" |"+_+"|\n"}.mkString+" |_|\n/___\\\n VvV")

AmazingDreams

Posted 2016-08-26T06:13:09.950

Reputation: 281

2

Python 3, 78 75 Bytes

w="  |\n /_\\"
for i in input(): w+="\n |"+i+"|"
w+="\n |_| \n/___\\ \n VvV"
print(w)

Thanks @ValueInk for spotting that I could lose 3 bytes by clearing the input function of arguments.

sonrad10

Posted 2016-08-26T06:13:09.950

Reputation: 535

Asking adding a character to print when asking for input input(">") is wholly unnecessary and you could save bytes by just calling input() – Value Ink – 2016-08-26T22:06:57.443

@ValueInk thanks, I had forgotten that you could leave the input command blank. – sonrad10 – 2016-08-26T22:10:47.280

2

MATLAB, 94 bytes

@(s)char(['  |';' /_\';arrayfun(@(x)[' |' x '|'],s,'UniformOutput',0)';' |_|';'/___\';' VvV'])

Anonymous function

user_C

Posted 2016-08-26T06:13:09.950

Reputation: 31

2Not sure about MATLAB, but in Octave you can replace false with 0 to save 4 bytes. – Dennis – 2016-08-30T15:54:03.010

2

S.I.L.O.S, 157 154 143 bytes

pL   |
def p print : lbl L Line
pL  /_\
loadL :
a = 256
:a
x = get a
if x c
GOTO e
:c
p  |
pChar x
pL |
a + 1
if x a
:e
pL  |_|
pL /___\
p  VvV

It should be fairly readable. Feel free to try it online!

Rohan Jhunjhunwala

Posted 2016-08-26T06:13:09.950

Reputation: 2 569

@LeakyNun :( just out of curiosity how can you see null bytes so I can self-debug next time. – Rohan Jhunjhunwala – 2016-08-26T16:41:28.803

@LeakyNun oh ok, I found the issue. Its all fixed up now – Rohan Jhunjhunwala – 2016-08-26T16:47:47.907

143 bytes – Leaky Nun – 2016-08-26T17:37:48.597

2

R, 116 bytes

Golfed

write(c("  |"," /_\\",sapply(strsplit(scan(,""),"")[[1]],function(y)paste0(" |",y,"|"))," |_|","/___\\"," VvV"),1,1)

Ungolfed

write(                                             # Write to console
      x = c("  |"," /_\\",                         # Add in stock rocket part  
        sapply(X = strsplit(scan(,""),"")[[1]],    # Take in rocket part specification, split string, loop over all specs
               FUN = function(y) {                 
                 paste0(" |",y,"|"))               # Custom build rocket body
                },
        " |_|","/___\\"," VvV"),                   # Add stock parts  
      file = 1,                                    # Print to console
      ncolumns = 1)

  |
 /_\
 |s|
 |t|
 |r|
 |s|
 |p|
 |l|
 |i|
 |t|
 |!|
 |_|
/___\
 VvV

Vlo

Posted 2016-08-26T06:13:09.950

Reputation: 806

2

Lua, 69 68 bytes

print([[  |
 /_\
]]..(...):gsub('.',' |%0|\n')..[[ |_|
/___\
 VvV]])

Should work with Lua 5.1 - 5.3 (tested with 5.3).

I don't have enough rep to comment on nolan's answer, but this is quite similar.

I'm using [[long string]] syntax to save a few bytes by avoiding needing to escape newlines and backslashes.

gsub doesn't need to specify a capture because %0 can be used. (Actually, %1 still works without a capture as well, but this isn't strictly documented.)

I also trimmed away the input validation; not sure why it was there -- an empty string input (as opposed to empty input) will work fine. Handling a missing arg[1] can be done more briefly just by (arg[1]or''):gsub(...) anyway, although at this point it is briefer just to switch to io.read() and get the input from stdin. Anyway, ... is a shorter way to get command-line input (even if parens are needed).

tehtmi

Posted 2016-08-26T06:13:09.950

Reputation: 446

2

Perl 6, 51 bytes

{"  |
 /_\\
 {("|$_|
"for |.comb,'_')}/___\\
 VvV"}

A lambda that takes a string as argument, and returns a string.

try it online

smls

Posted 2016-08-26T06:13:09.950

Reputation: 4 352

2

R, 101 bytes

This is an improvement on Frédéric's answer. I eliminated the variable definition, the for-loop, and the need for the sep="" argument.

cat("  |\n /_\\\n",sapply(strsplit(scan(,""),""),function(x)paste0("|",x,"|\n")),"|_|\n/___\\\n VvV")

Ungolfed:

cat("  |\n /_\\\n",                      # Print top of rocket
    sapply(
      strsplit(scan(,""),""),            # Take stdin and convert to list of chars
      function(x)paste0("|",x,"|\n")),   # Print letters
    ,"|_|\n/___\\\n VvV")                # Print bottom and FLAMES

I'm sure that there is still some improvement possible.

rturnbull

Posted 2016-08-26T06:13:09.950

Reputation: 3 689

1Needs " |\n /_\\\n", but never thought about hard coding \n – Vlo – 2016-08-29T13:27:56.593

@Vlo Thanks, that's fixed now. (It is correct in my ungolfed/explained version, so I must have just pasted the wrong version in the first instance. The byte count is unchanged, thankfully.) – rturnbull – 2016-08-29T22:32:35.143

2

Dyalog APL, 50 bytes

↑'/___\' ' VvV',⍨'  |' ' /_\',↓' ','|',⍨'|',⍪⍞,'_'

OK, so it may not be the shortest submission, but it is the only one that carries the name of a real rocket manufacturer:

  |  
 /_\ 
 |A| 
 |P| 
 |L| 
 |_| 
/___\
 VvV 

TryAPL online!

Adám

Posted 2016-08-26T06:13:09.950

Reputation: 37 779

2

><>, 60 bytes

'  |'a' /_\'av
a$v?(0:i'|| '<
'r\~'_'$a'/___\'a' VvV
 o>l?!;

Pretty simple really. lots of strings, the newlines are annoying.

Try it online

  |
 /_\
 |>|
 |<|
 |>|
 |_|
/___\
 VvV

torcado

Posted 2016-08-26T06:13:09.950

Reputation: 550

2

Swift, 99 byte

let f:(String)->String={$0.characters.reduce("  |\n /_\\\n"){$0+" |\($1)|\n"}+" |_|\n/___\\\n VvV"}

Use like this:

print(f("Some String"))

Result:

  |
 /_\
 |S|
 |o|
 |m|
 |e|
 | |
 |S|
 |t|
 |r|
 |i|
 |n|
 |g|
 |_|
/___\
 VvV

Sven

Posted 2016-08-26T06:13:09.950

Reputation: 121

2

Perl, 51 bytes

50 bytes code + 1 for -p.

s/./$&|
 |/g;s~^~  |
 /_\\
 |~;s~$~_|
/___\\
 VvV~

Usage

perl -pe 's/./$&|
 |/g;s~^~  |
 /_\\
 |~;s~$~_|
/___\\
 VvV~' <<< earth
  |
 /_\
 |e|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
perl -pe 's/./$&|
 |/g;s~^~  |
 /_\\
 |~;s~$~_|
/___\\
 VvV~' <<< ''
  |
 /_\
 |_|
/___\
 VvV
perl -pe 's/./$&|
 |/g;s~^~  |
 /_\\
 |~;s~$~_|
/___\\
 VvV~' <<< '0|'
  |
 /_\
 |0|
 |||
 |_|
/___\
 VvV

Dom Hastings

Posted 2016-08-26T06:13:09.950

Reputation: 16 415

2

Dart, 80 bytes

g(s)=>'  |\n /_\\\n${s.split('').map((s)=>' |$s|\n').join()} |_|\n/___\\\n VvV';

Running it through

main()=>print(g("Jasper"));

Gives:

  |
 /_\
 |J|
 |a|
 |s|
 |p|
 |e|
 |r|
 |_|
/___\
 VvV

Jasper Catthoor

Posted 2016-08-26T06:13:09.950

Reputation: 51

1

Python 3, 83 Bytes

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

Juntos

Posted 2016-08-26T06:13:09.950

Reputation: 41

72 bytes. – Jonathan Frech – 2017-11-01T21:22:44.303

1

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

Taylor Scott

Posted 2016-08-26T06:13:09.950

Reputation: 6 709

1

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.

Chris

Posted 2016-08-26T06:13:09.950

Reputation: 1 313

1

SOGL V0.12, 27 24 bytes

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

Try it Here!

dzaima

Posted 2016-08-26T06:13:09.950

Reputation: 19 048

1

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

kalsowerus

Posted 2016-08-26T06:13:09.950

Reputation: 1 894

1

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 "

Taylor Scott

Posted 2016-08-26T06:13:09.950

Reputation: 6 709

1

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!

Quantum64

Posted 2016-08-26T06:13:09.950

Reputation: 371

1

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

sugarfi

Posted 2016-08-26T06:13:09.950

Reputation: 1 239

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!

– Value Ink – 2019-07-27T00:35:12.650

1

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

Dr Y Wit

Posted 2016-08-26T06:13:09.950

Reputation: 511

1

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.

Kenneth Taylor

Posted 2016-08-26T06:13:09.950

Reputation: 183

1

Haskell, 67 63 59 bytes

(++"_|\n/___\\\n VvV").("  |\n /_\\\n |"++).(>>=(:"|\n |"))

Thanks to Damien it's now essentially the same as xnor's answer, just in point-free notation. Ideone it!

Laikoni

Posted 2016-08-26T06:13:09.950

Reputation: 23 676

I never use concatMap. You should use >>= or =<<instead. concatMap f s is the same as f=<<s or s>>=f – Damien – 2016-08-26T12:00:07.260

1

C#, 130 111 95 bytes

s=>{var a="  |\n /_\\\n";foreach(var c in s)a+=" |"+c+"|\n";a+=" |_|\n/___\\\n VvV";return a;};

Saved 16 bytes thanks to Kevin Cruijssen

TheLethalCoder

Posted 2016-08-26T06:13:09.950

Reputation: 6 930

Trailing whitespaces are optional, so a=" | \n"; can be a=" |\n";. Same applies to a few other lines. Also, why the a+="111";a+="222";a+="333";? You can just do this once: a+="111222333";. Total becomes: s=>{var a=" |\n /_\\\n";for(int i=0;i<s.Length;)a+=" |"+s[i++]+"|\n";return a+" |_|\n/___\\\n VvV";}; (103 bytes) Also, I'm not entirely sure, but isn't a foreach with characters shorter than your for-loop? – Kevin Cruijssen – 2016-08-26T12:13:51.270

1

Batch, 128 bytes

@echo off
set s=%1_
echo   ^|
echo  /_\
:l
echo  ^|%s:~0,1%^|
set s=%s:~1%
if not "%s%"=="" goto l
echo /___\
echo  VvV

Neil

Posted 2016-08-26T06:13:09.950

Reputation: 95 035

1

Javascript (using external lib - Enumerable) (84 bytes)

n=>" |\n /_\\\n"+_.From(n).WriteLine(x=>" |"+x+"|")+(n?"\n":'')+" |_|\n/___\\\n VvV"

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Pretty straight forward. Just boilerplates the rocketship template (top and bottom), and concats the fuselage string in the middle. Whats eating up a lot of bytes is the check if the input is truthy, because for an empty string it's wrong to add a newline to the beginning of the bottom template

I love how the native JS answer blows this away...

enter image description here

applejacks01

Posted 2016-08-26T06:13:09.950

Reputation: 989

1

Perl, 65 60 bytes

say'  |
 /_\\';say" |$_|"for split'',<>;say' |_|
/___\
 VvV'

Needs -E to use say, input should be piped in in order to not have a trailing newline. Notice that there's a space at the beginning of the second and fourth lines. Takes advantage of being able to use literal new lines in Perl to save a byte over using \n in each of the cases

Thanks to @manatwork for saving 5 bytes!

theLambGoat

Posted 2016-08-26T06:13:09.950

Reputation: 119

I'm afraid you did the same mistake as I did – you forgot the |_|.

– manatwork – 2016-08-26T18:21:54.273

@manatwork Nope! the s/\n/_/ adds it in since input in Perl comes with a new line character at the end, I'm swapping it for the underscore and it's handled as an additional character in the loop – theLambGoat – 2016-08-26T18:22:54.690

Strange. I get the output without it: http://pastebin.com/QB2qMuSE Oh, I see, this is newline dependent. As the question owner wrote that will be no newline in input, I tried without.

– manatwork – 2016-08-26T18:26:03.393

Oh! Instead of piping in the input, execute the file and then type the input (followed by pressing enter to end the input). The enter from that is what gets translated to the _. Alternately, replace the first newline with $ in order to be able to pipe in input (but not enter it manually) for the same byte count – theLambGoat – 2016-08-26T18:29:08.283

Interesting choice, given it would be shorter without that newline handling: http://pastebin.com/QXRFdJwU

– manatwork – 2016-08-26T18:37:54.983

I guess I've just always assumed that passing input had to be done manually and I was forced to deal with the new line. If I'm allowed to use echo to pass it in though, that's definitely the better solution – theLambGoat – 2016-08-26T18:47:41.713

1

Neoscript, 76 bytes

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

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

TuxCrafting

Posted 2016-08-26T06:13:09.950

Reputation: 4 547

1

MUMPS: 94 bytes

To get some more variety in here. I tried to solve this in C by declaring main as an array of integers that were compiled machine code but it was still too big, especially on a 64 bit machine.

r
 r x w !,"  |",!," /_\",! f i=1:1:$L(x) w " |",$E(x,i),"|",!
 w " |_|",!,"/___\",!," VvV" q

R Jesu

Posted 2016-08-26T06:13:09.950

Reputation: 111

1

MATL, 47 42 41 bytes

95h"' |'@yPhh]v'   /|_ \'2ew'/ _V_v_V\'2e

Try it online!

Luis Mendo

Posted 2016-08-26T06:13:09.950

Reputation: 87 464

1

Clojure (83 bytes)

#(str "  |\n /_\\\n |" (clojure.string/join "|\n |" (str % \_)) "|\n/___\\\n VvV")

And here's a rocket for you:

  |
 /_\
 |W|
 |e|
 |l|
 |c|
 |o|
 |m|
 |e|
 | |
 |t|
 |a|
 | |
 |E|
 |a|
 |r|
 |f|
 |_|
/___\
 VvV

James B.

Posted 2016-08-26T06:13:09.950

Reputation: 51

1

Javascript (ES5), 109 89 Bytes)

function(n){s=" |\n /_\\\n |";for(i=0;c=n[i++];)s+=c+"|\n |";return s+"_|\n/___\\\n VvV"}

Ungolfed:

function a(n){
var str="  |\n /_\\\n";
for(var i=0;i<n.length;i++){
str+=" |"+n[i]+"|\n";
}
return str+" |_|\n/___\\\n VvV";
}

EDIT: Saved 20 Bytes thanks to manatwork!

Paul Schmitz

Posted 2016-08-26T06:13:09.950

Reputation: 1 089

1You have a small bug: the flame is not centered. That will cost you 1 character, but there are a couple of them you can remove: user shorter variable name; do not enclose the single instruction repeated by for in braces; increment the counter when you use it, instead of for's 3rd parameter; rearrange the strings to use a single string literal in the loop; test whether string end is reached by current character, not by .length; and anonymous functions are acceptable: function(n){s=" |\n /_\\\n |";for(i=0;c=n[i++];)s+=c+"|\n |";return s+"_|\n/___\\\n VvV"}. – manatwork – 2016-08-27T15:20:26.503

1

Java 8, 132 109 107 96 Bytes

i->"  |\n /_\\ \n"+i.chars().mapToObj(c->" |"+(char)c+"|")
                            .collect(joining("\n"))+"\n |_|\n/___\\\n VvV"

CoderCroc

Posted 2016-08-26T06:13:09.950

Reputation: 337

How do you run this? This doesn't seem to be a complete method... – stommestack – 2016-08-30T16:22:00.920

2@JopV. Yes it's a lambada expression, this is a Function<String, String> in Java-8 to be applied on any string value. Correct me if I have mistaken. – CoderCroc – 2016-08-30T16:32:12.047

Your submission shouldn't have whitespace added (you can include a separate readable version with spaces). Also it looks like you're using a static import of java.util.stream.Collectors.joining, so that statement should be included in your submission and byte count. And please mention that lambda type in your solution. – Jakob – 2017-08-29T17:00:06.583

1

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

rnso

Posted 2016-08-26T06:13:09.950

Reputation: 1 635

0

Pyth, 44 bytes

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

Try it online!

clap

Posted 2016-08-26T06:13:09.950

Reputation: 834

0

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

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

Try it online!

Xcali

Posted 2016-08-26T06:13:09.950

Reputation: 7 671

0

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!

jq170727

Posted 2016-08-26T06:13:09.950

Reputation: 411

0

Ruby, 53 bytes

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

Try it online!

Reinstate Monica -- notmaynard

Posted 2016-08-26T06:13:09.950

Reputation: 1 053

0

J, 52 46 45 bytes

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

Try it online!

FrownyFrog

Posted 2016-08-26T06:13:09.950

Reputation: 3 112

0

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.

Patrick Roberts

Posted 2016-08-26T06:13:09.950

Reputation: 2 475

0

><>, 52 bytes

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

Try It Online

Adds everything to the stack before printing.

Jo King

Posted 2016-08-26T06:13:09.950

Reputation: 38 234

0

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.

Giuseppe

Posted 2016-08-26T06:13:09.950

Reputation: 21 077

0

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!

Taylor Scott

Posted 2016-08-26T06:13:09.950

Reputation: 6 709

I think you can save three bytes by putting the entire for loop onto one line. – Jonathan Frech – 2018-07-12T14:48:01.283

@JonathanFrech You are absolutely right - I can't believe I missed that. – Taylor Scott – 2018-07-12T17:47:34.670

0

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.

AlexRacer

Posted 2016-08-26T06:13:09.950

Reputation: 979

0

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

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

Try it online.

Denis Ibaev

Posted 2016-08-26T06:13:09.950

Reputation: 876

0

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)

Kevin Cruijssen

Posted 2016-08-26T06:13:09.950

Reputation: 67 575

0

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.

Giuseppe

Posted 2016-08-26T06:13:09.950

Reputation: 21 077

0

Python 3, 81 bytes

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

Try it online!

Dat

Posted 2016-08-26T06:13:09.950

Reputation: 879

0

Stax, 25 bytes

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

Run and debug it

recursive

Posted 2016-08-26T06:13:09.950

Reputation: 8 616

0

perl6 - 69

say "  |\n /-\\\n |{@*ARGS.comb.join("|\n |")}|\n |_|\n/___\\\n VvV"

tonyo

Posted 2016-08-26T06:13:09.950

Reputation: 1

1

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.

– mbomb007 – 2019-08-02T18:12:16.977

0

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

TheOnlyMrCat

Posted 2016-08-26T06:13:09.950

Reputation: 1 079

0

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

Kenneth Taylor

Posted 2016-08-26T06:13:09.950

Reputation: 183

0

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')
```

MysteryCoder456

Posted 2016-08-26T06:13:09.950

Reputation: 1

0

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

canttalkjustcode

Posted 2016-08-26T06:13:09.950

Reputation: 131

0

JavaScript 63

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

executed using s("test") for example.

WallyWest

Posted 2016-08-26T06:13:09.950

Reputation: 6 949

0

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

Brian

Posted 2016-08-26T06:13:09.950

Reputation: 1 209

0

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 

goks

Posted 2016-08-26T06:13:09.950

Reputation: 101

0

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

flederwiesel

Posted 2016-08-26T06:13:09.950

Reputation: 111

0

sed, 51 bytes

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

Each line from stdin produces a new rocket on stdout.

Toby Speight

Posted 2016-08-26T06:13:09.950

Reputation: 5 058

0

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!

stommestack

Posted 2016-08-26T06:13:09.950

Reputation: 234

Do not declare i separately as int, just enumerate it at var. – manatwork – 2016-08-30T16:15:59.237

@manatwork What do you mean? How would you not have to declare i? – stommestack – 2016-08-30T16:25:13.140

You have, but var is fine for i too: var o=' |\n /_\\\n',i=0. – manatwork – 2016-08-30T16:38:23.433

Ah, thanks! I didn't know Dart had that! – stommestack – 2016-08-30T17:06:06.430

0

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

seshoumara

Posted 2016-08-26T06:13:09.950

Reputation: 2 878

0

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!

ATaco

Posted 2016-08-26T06:13:09.950

Reputation: 7 898

0

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.

Zatherz

Posted 2016-08-26T06:13:09.950

Reputation: 111