6 kyu

Bus ASCII-Art Animation

Description:

What is an ASCII Art?

ASCII Art is art made of basic letters and symbols found in the ascii character set.

Example of ASCII Art (by Joan Stark)

            _     _                     /              _
           (')-=-(')                 __|_             {_}
         __(   "   )__              |____|            |(|
        / _/'-----'\_ \             |    |            |=|
     ___\\ \\     // //___          |    |           /   \
     (____)/_\---/_\(____)          \____/           |.--|
                                                     ||  |
                                                     ||  |    .    ' .
                                                     |'--|  '     \~~~/
                                                     '-=-' \~~~/   \_/
                                                            \_/     Y
                                                             Y     _|_
                                                            _|_

Your Goal

Write a function that takes in:

  • The size of the bus
  • The speed of the bus
  • The number of frames for the animation
  • The size for how big a frame will be per line

The output should be a single multi-line string, each frame being seperated by frame size number of dashes and a newline character.

How to Make the Bus

This is the base shape of the bus (when size = 1):

 _____________
|   |    | |  \  
|___|____|_|___\ 
|        | |    \
`--(o)(o)--(o)--'

With each increase in size, an additional middle section is added. Here are the example for size = 2 and size = 3 respectively:

 __________________
|   |    |    | |  \  
|___|____|____|_|___\ 
|             | |    \
`--(o)(o)-------(o)--'

 _______________________
|   |    |    |    | |  \  
|___|____|____|____|_|___\ 
|                  | |    \
`--(o)(o)------------(o)--'

How to Make the Animation

  • Each iteration of the frames should make the bus "move forward" by bus speed spaces.
  • Each line of a frame should always be the size of frame size, if the generated frame is more narrow than that, fill the ends of the lines with spaces. If it is wider, cut the characters exceeding the frame's lines.

Technicalities

  • Buses will never have a size less than 1
  • Buses will never have a speed less than 0
  • New line characters will not count as part of the frame size

Solution Examples

Example #1

bus size = 1, bus speed = 2, frame count = 5, frame size = 20

 _____________      
|   |    | |  \     
|___|____|_|___\    
|        | |    \   
`--(o)(o)--(o)--'   
                    
--------------------
   _____________    
  |   |    | |  \   
  |___|____|_|___\  
  |        | |    \ 
  `--(o)(o)--(o)--' 
                    
--------------------
     _____________  
    |   |    | |  \ 
    |___|____|_|___\
    |        | |    
    `--(o)(o)--(o)--
                    
--------------------
       _____________
      |   |    | |  
      |___|____|_|__
      |        | |  
      `--(o)(o)--(o)
                    
--------------------
         ___________
        |   |    | |
        |___|____|_|
        |        | |
        `--(o)(o)--(

Example #2

bus size = 3, bus speed = 5, frame count = 4, frame size = 35

 _______________________           
|   |    |    |    | |  \          
|___|____|____|____|_|___\         
|                  | |    \        
`--(o)(o)------------(o)--'        
                                   
-----------------------------------
      _______________________      
     |   |    |    |    | |  \     
     |___|____|____|____|_|___\    
     |                  | |    \   
     `--(o)(o)------------(o)--'   
                                   
-----------------------------------
           _______________________ 
          |   |    |    |    | |  \
          |___|____|____|____|_|___
          |                  | |   
          `--(o)(o)------------(o)-
                                   
-----------------------------------
                ___________________
               |   |    |    |    |
               |___|____|____|____|
               |                  |
               `--(o)(o)-----------

Example #3

bus size = 2, bus speed = 0, frame count = 5, frame size = 25

 __________________      
|   |    |    | |  \     
|___|____|____|_|___\    
|             | |    \   
`--(o)(o)-------(o)--'   
                         
-------------------------
 __________________      
|   |    |    | |  \     
|___|____|____|_|___\    
|             | |    \   
`--(o)(o)-------(o)--'   
                         
-------------------------
 __________________      
|   |    |    | |  \     
|___|____|____|_|___\    
|             | |    \   
`--(o)(o)-------(o)--'   
                         
-------------------------
 __________________      
|   |    |    | |  \     
|___|____|____|_|___\    
|             | |    \   
`--(o)(o)-------(o)--'   
                         
-------------------------
 __________________      
|   |    |    | |  \     
|___|____|____|_|___\    
|             | |    \   
`--(o)(o)-------(o)--'   
ASCII Art
Puzzles

More By Author:

Check out these other kata created by Joe Reece

Stats:

CreatedJan 9, 2022
PublishedJan 9, 2022
Warriors Trained182
Total Skips3
Total Code Submissions284
Total Times Completed68
Python Completions68
Total Stars16
% of votes with a positive feedback rating92% of 24
Total "Very Satisfied" Votes20
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Joe Reece Avatar
  • FArekkusu Avatar
Ad