-3
\$\begingroup\$

This code golf challenge is about making a rocket liftoff sequence.
Your output (STDOUT) should be equal to this:

Liftoff in T-10
Liftoff in T-9
Liftoff in T-8
Liftoff in T-7
Liftoff in T-6
Liftoff in T-5
Liftoff in T-4
Liftoff in T-3
Liftoff in T-2
Liftoff in T-1
LIFTOFF!

Rules:

  • Your output must print to STDOUT.
  • Your program must not raise any errors.
  • This is code golf, shortest code in bytes wins.
\$\endgroup\$
11
  • 10
    \$\begingroup\$ What does it mean for the output to be "similar to this"? You should specify it exactly. And is the "..." in the output something we actually print verbatim, or does it stand for the middle part of the sequence? \$\endgroup\$
    – xnor
    Dec 3, 2020 at 13:15
  • 6
    \$\begingroup\$ Welcome to Code Golf! We have a couple of default rules that should not be overridden unless there's a good reason to because of the nature of the challenge (which is not the case here). For instance, code golf submissions are programs or functions by default and you should not make assumptions about languages features. \$\endgroup\$
    – Arnauld
    Dec 3, 2020 at 13:25
  • \$\begingroup\$ Does this look better? \$\endgroup\$ Jan 4, 2021 at 22:51
  • 1
    \$\begingroup\$ @manatwork While either of those twists would make it new I don't think either of them would benefit the challenge at all. It's better to just come up with a new challenge than try to add a twist to a bad one. \$\endgroup\$
    – Wheat Wizard
    Jan 5, 2021 at 17:23
  • 1
    \$\begingroup\$ Does this answer your question? "99 Bottles of Beer" \$\endgroup\$
    – Fmbalbuena
    Jan 27, 2022 at 17:30

12 Answers 12

5
\$\begingroup\$

Java (JDK), 92 79 78 bytes

v->{for(int i=11;i-->0;)System.out.println(i>0?"Liftoff in T-"+i:"LIFTOFF!");}

Try it online!

Edit: Thanks to @KevinCruijssen for -1 byte

\$\endgroup\$
1
  • \$\begingroup\$ --i>=0 to i-->0 for -1 byte. :) \$\endgroup\$ Dec 3, 2020 at 13:57
3
\$\begingroup\$

APL (Dyalog Unicode), 36 bytes (SBCS)

Full program.

↑'Liftoff in T-'∘,∘⍕¨⌽⍳10
'LIFTOFF!'

Try it online!

ɩndices 1 through 10
 reverse them
¨ on each number, do:
 format as text
 then:
  , prepend
   the entirety of:
   'Liftoff in T-' this string
 merge list of strings into character matrix (and implicitly output to stdout)

'LIFTOFF!' this string (implicitly output it to stdout)

\$\endgroup\$
4
  • 3
    \$\begingroup\$ I've seen it before, but how do you even post an answer if the question is already closed.. It's closed 19 minutes ago, yet your answer is from 7 minutes ago.. :S \$\endgroup\$ Dec 3, 2020 at 13:56
  • 2
    \$\begingroup\$ Why is 0 included in the string? \$\endgroup\$
    – vrintle
    Dec 3, 2020 at 14:00
  • 4
    \$\begingroup\$ @KevinCruijssen, you can still post from the mobile app if you don't refresh first. \$\endgroup\$
    – Shaggy
    Dec 3, 2020 at 14:57
  • \$\begingroup\$ @vrintle Fixed. Thanks. \$\endgroup\$
    – Adám
    Dec 3, 2020 at 14:59
3
\$\begingroup\$

Python 2, 56 bytes

d=11
exec"'Liftoff in T-%d'%d;d-=1;print"*d+"'LIFTOFF!'"

Try it online!

Wonderful application of Using exec to remove repeated print.

-1 thanks to dingledooper who realised we can reuse the d variable in the exec multiplier.

Python 2, 57 bytes

d=~9
while d:print"Liftoff in T%d"%d;d+=1
print"LIFTOFF!"

Try it online!

Python 2, 59 bytes

d=10
while d:print"Liftoff in T-%d"%d+1/d*"\nLIFTOFF!";d-=1

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Wonderful! I believe you can save one more byte Try it online! \$\endgroup\$ Jan 5, 2021 at 1:38
  • \$\begingroup\$ @dingledooper That's beautiful. Love it! \$\endgroup\$
    – Sisyphus
    Jan 5, 2021 at 1:42
2
\$\begingroup\$

Ruby 2.7, 51 50 bytes

Saved a byte using ~9 for -10, thanks to Sisyphus!

puts (~9..-1).map{"Liftoff in T#{_1}"}<<"LIFTOFF!"

Try it online!

TIO uses an older version of Ruby, whereas in Ruby 2.7, we've numbered parameters, which saves two bytes.


Ruby, 57 bytes

puts"Liftoff in T-#{11-($.+=1)}"while$.<10
puts"LIFTOFF!"

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ For the 51 character version better mention that uses Ruby 2.7 numbered block parameter, for people to know why it doesn't work on TIO's Ruby 2.5.5. \$\endgroup\$
    – manatwork
    Jan 5, 2021 at 4:28
  • \$\begingroup\$ Thanks @manatwork, I really forgot to add it. \$\endgroup\$
    – vrintle
    Jan 5, 2021 at 4:53
  • 1
    \$\begingroup\$ -10 -> ~9 for -1 byte \$\endgroup\$
    – Sisyphus
    Jan 5, 2021 at 5:09
  • \$\begingroup\$ Nice, @Sisyphus ;-) \$\endgroup\$
    – vrintle
    Jan 5, 2021 at 5:14
2
\$\begingroup\$

Bash, 67 bytes

for i in `seq 10`;do echo Liftoff in T-$((11-i));done;echo LIFTOFF!

Try it online!

Bash, 43 bytes

thanks to @Sisyphus for this suggestion.

seq -f'Liftoff in T%g' -10 -1;echo LIFTOFF!

Try it online

\$\endgroup\$
2
  • \$\begingroup\$ You're not supposed to include 0. \$\endgroup\$
    – xigoi
    Jan 5, 2021 at 20:03
  • 1
    \$\begingroup\$ 43 bytes \$\endgroup\$
    – Sisyphus
    Jan 7, 2021 at 8:51
1
\$\begingroup\$

Perl 5, 43 bytes

say"Liftoff in T$_"for-10..-1;say'LIFTOFF!'

Try it online!

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

PowerShell Core, 37 bytes

10..1|%{"Liftoff in T-$_"}
"LIFTOFF!"

Try it online!

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

Jelly, 25 24 bytes

“ÞÆdḂbMG:ȯ»;Ɱ⁵ṚY⁷“KçÞ»Œu

Try it online!

-1 byte thanks to caird

Explanation

“ÞÆdḂbMG:ȯ»;Ɱ⁵ṚY⁷“KçÞ»Œu   Main niladic link
“ÞÆdḂbMG:ȯ»                "Liftoff in T-"
           ;               Join with
            Ɱ              each of
             ⁵             [1 to] 10
              Ṛ            Reverse
               Y           Join with newlines
                           Print and discard
                ⁷          Newline
                           Print and discard
                 “KçÞ»     "liftoff!"
                      Œu   Uppercase
\$\endgroup\$
3
  • 1
    \$\begingroup\$ -1 byte \$\endgroup\$ Jan 5, 2021 at 17:12
  • \$\begingroup\$ @cairdcoinheringaahing Thanks! I've been confused by unpaired nilads in links and I think this clears them up. \$\endgroup\$
    – xigoi
    Jan 5, 2021 at 17:16
  • 1
    \$\begingroup\$ They're mainly very helpful if you just want to print and discard something :) \$\endgroup\$ Jan 5, 2021 at 17:17
1
\$\begingroup\$

Nim, 54 53 bytes

for i in -10..<0:echo "Liftoff in T",i
echo"LIFTOFF!"

Try it online!

-1 byte by using the negative numbers trick from other answers

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

05AB1E, 30 bytes

TFNT-“ƒŸ€† Tÿ“'µë™ì,}’µëƒŸ!’u,

Try it online!

TFNT-“ƒŸ€† Tÿ“'µë™ì,}’µëƒŸ!’u,  # full program
 F                              # for N in [0, 1, 2, ...,
T                               # ..., 10...
 F                              # minus 1]...
                   ,            # print...
     “ƒŸ€† Tÿ“                  # "off in Tÿ"...
                                # (implicit) with ÿ replaced by...
  N                             # variable...
    -                           # minus...
   T                            # 10...
                  ì             # prepended with...
              'µë               # "lift"...
                 ™              # in title case...
                   ,            # with trailing newline
                    }           # end loop
                             ,  # print...
                     ’µëƒŸ!’    # "liftoff!"...
                            u   # in uppercase...
                             ,  # with trailing newline
\$\endgroup\$
0
\$\begingroup\$

Deadfish~, 1402 bytes

{{i}ddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}iciiiicdc{{d}iiiiii}iic{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}iic{{d}iiiii}iiic{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}ic{{d}iiiiii}ddddddc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}c{{d}iiiiii}dddddc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}dc{{d}iiiiii}ddddc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}ddc{{d}iiiiii}dddc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}ic{i}dddc{{d}iiiiii}ddc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}iciiiiiic{{d}iiiiii}dc{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}iciiiiic{{d}iiiiii}c{{i}dddd}iiiiiic{i}{i}{i}dcdddc{i}iiiicdddddc{d}icc{{d}iii}c{{i}ddd}iiiciiiiic{{d}ii}iic{{i}ddddd}iic{{d}iiiiii}iciiiic{{d}iiiiii}ic{{i}dddd}iiiiiicdddcdddc{i}iiiicdddddc{d}icc{{d}iiiiii}iiic

Try it online!

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

Vyxal j, 32 bytes

₀ɾṘƛ«ƛ⟇⋏∨e«¡:£` in T-`+n+;¥⇧\!+J

Try it Online!

\$\endgroup\$

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