Consider these seven ASCII train cars.
Engine (E)
__
====== \/
| [] |=========
| )
================
O-O-O O-O-O \\
Passenger car (P)
===============
| [] [] [] [] |
===============
O-O O-O
Boxcar (B)
===============
|-|-| | |-|-|
===============
O-O O-O
Tanker (T)
_____---_____
( )
===============
O-O O-O
Hopper (H)
_______________
\ | | | | | | /
===============
O-O O-O
Flatbed (F)
===============
O-O O-O
Caboose (C)
=====
====| |====
| [] [] |
=============
O-O O-O
Write a program that when given a sequence of the characters EPBTHFC
, outputs its ASCII train representation, using --
for the car couplings. The leftmost input characters become the rightmost train cars. The train is always facing right.
For example, an input of EEHTBPFC
should produce
__ __
===== ====== \/ ====== \/
====| |==== =============== =============== _____---_____ _______________ | [] |========= | [] |=========
| [] [] | | [] [] [] [] | |-|-| | |-|-| ( ) \ | | | | | | / | ) | )
=============--===============--===============--===============--===============--===============--================--================
O-O O-O O-O O-O O-O O-O O-O O-O O-O O-O O-O O-O O-O-O O-O-O \\ O-O-O O-O-O \\
Details
- This is code golf; the shortest program in bytes wins.
- Any sequence of one or more of the letters
EPBTHFC
is valid input. - Your program must be able to output all 7 car types exactly as they appear above.
- Take input from the command line or directly from the user (e.g. message box). Output to stdout. (Quotes around input are fine.)
- The height of the output should either be 6 or the maximum height needed for the train cars being drawn.
- Do not put couplings (
--
) at the front of the first car or the back of the last car.
E
at the front and could there be anE
somewhere in the middle? \$\endgroup\$