24
4
EDIT
It appears that there has been some confusion following my typo in the original post which used a lowercase o to define the plane and then an uppercase later. Unfortunately this bug did not get picked up in the Sandbox. Since many members have written answers with both and since the typo was my fault I will allow either uppercase or lowercase o in the definition of the plane. I have added a new rule for this.
Background
I like ascii art animations as I tend to call them so here is another one. I don't think this is too difficult to implement so will hopefully get some short and interesting answers.
To all fellow community members
If you improve on your answer please modify your byte count as
old byte count new byte count
so we can see your progress. Thanks!
Challenge
Here is an ascii plane
--O--
Here is an ascii runway
____| |____
The plane starts at 5 newlines above the runway. To prevent any clashes between metric and imperial systems and make this a truly international challenge I won't mention meters or feet. Example:
--O--
____| |____
The Plane must land exactly in the middle of the runway as shown below:
____|--O--|____
Input
The initial horizontal position of the plane is defined by an integer input which is used to reference the tip of the left wing i.e. it is between 0 and 10 inclusive.
Output
Each stage of the planes flight must be shown. Example below (input=10):
--O--
____| |____
--O--
____| |____
--O--
____| |____
--O--
____| |____
--O--
____| |____
____|--O--|____
To keep things simple, we are ignoring the laws of perspective. The runway stays the same size as you get closer.
Rules
- Update The middle of the plane can be either an uppercase or lowercase o but whichever is chosen must be consistent throughout the code. If your language does not support the characters above feel free to use alternative ascii only characters.
- The plane descends 1 line per frame.
- The plane can only move 1 space to the left or right each time it descends one line. It does not have to move on each line of descent. As long as it finishes on the runway it is up to you when it moves right or left. You're the pilot!
- No error handling required. You may assume that the input will always be a valid integer from 0-10 inclusive.
- Output must consist of only the characters shown above (if your language does not support them the see edited first rule) and must be the same size i.e. must start 6 lines high by 15 characters wide. The height can decrease as it progresses as in the example above.
- Program or function is fine but must produce an output as shown above.
- Leading/trailing spaces/newlines are fine by me.
- Please feel free to clear the screen between output frames if you wish. This is not a requirement.
- Standard loopholes prohibited as usual (although I don't think there are many that would help with this kind of challenge).
- This is code golf so shortest answer is obviously the winner and will probably get most votes but may not necessarily be accepted as the best answer if some really interesting solution comes along in some unexpected language, even if it is longer. Feel free to post anything that meets the rules as long as it works.
Ungolfed reference implementation in Python 2 available at Try it online! so you can see how it looks for different input values.
I don't think it is kolmogorov-complexity as the output depends on the input – ovs – 2017-01-18T19:25:11.937
Thanks for the clarification @ovs. I'll remove that tag then. – ElPedro – 2017-01-18T19:25:59.497
Usually, the acceptance goes to the answer that complies best with the Objective Winning Criterion. You may get some flak if you accept another, longer answer. – Level River St – 2017-01-18T22:23:54.270
Thanks @LevelRiverSt. Is there a meta post to clarify this? If not then maybe better to not accept any answer. – ElPedro – 2017-01-18T22:26:12.317
btw, I have accepted a longer answer before and given credit to the shorter answer as well with no probs from the community Previous challenge. Please see my Result comment at the end of the question. Was this wrong?
– ElPedro – 2017-01-18T22:31:54.677I'm not going to say if it's right or wrong, as that's something the community should judge. In answer to your previous comment, here's a meta question by someone with similar views to you. There are probably other meta questions out there. Note the voting on his answer and Helka Homba's http://meta.codegolf.stackexchange.com/q/8706/15599
– Level River St – 2017-01-18T22:40:40.287Thanks for the link. Much as I respect your comments I'l go this my own way. If I get downvoted for what other community members think is the wrong decision on the accepted answer I will accept that. As I have said on a previous Meta post (2nd answer from the top), I don't think we should take this too seriously.
– ElPedro – 2017-01-18T22:52:15.587I'll just leave this here… (See full listing.) – wchargin – 2017-01-19T03:49:50.577
The plane is shown once in lowercase, and the rest of the time in uppercase. Are both variants allowed? (It does make a difference, see my Perl 6 solution...) – smls – 2017-01-19T10:32:32.317
@smls Good catch and thanks for pointing it out. The plane should be uppercase - I have corrected the question. Apologies for any confusion caused. – ElPedro – 2017-01-19T10:41:08.987
Thought it seems in the TI-BASIC responses (they used O, not o), _ and | were replaced with - and either / or I, so why would the O matter – Golden Ratio – 2017-01-20T00:23:53.693