1
1
Introduction
It was just a normal day, here at your military base. Suddenly, you looked up to see a bomb falling down from the sky! You need to create a program to predict where it will fall, and tell you the location.
Challenge
You will be given a bomb in the form of Start-X Start-Y X-velocity Y-velocity
. You can assume that they will all be positive integers. 0 is a valid input only for Start-x
and Start-y
. The bomb starts with x Start-x
, and y Start-y
. Each "frame" (no graphical output required), the bomb will move x-velocity
units right, then y-velocity
units down. Continue doing this until the bomb reaches y of 0 or below. Then, output what it's x was when it hit the ground.
Test Cases
1
Input:0 10 2 2
Output:10
2
Input:5 4 3 2
Output:11
3
Input:11,8,7,3
Output:32
This is code-golf, so shortest answer in bytes wins!
6Once you do out the math, it looks like the formula leaves little to golf. – xnor – 2017-04-04T21:23:38.373
@xnor Maybe the ceiling function could be golfed. But I can't see anywhere else. – fəˈnɛtɪk – 2017-04-04T21:24:30.583
You can assume that they will all be positive integers
0 is not a positive integer. Can you clarify if 0 is a valid input or not? – James – 2017-04-04T21:26:09.380Looks like 0 is valid input from test case #1 – Timtech – 2017-04-04T21:27:02.707
0 is a valid input only for start-x and start-y. editing now. – pydude – 2017-04-04T21:28:09.523
Since this is such a trivial question, please do not upvote answers in obvious or golfing languages.
– devRicher – 2017-04-05T09:50:52.837"Normal day", "military base" being in your "military base" isnt "normal". also, If you make a military base you might as well make it an explosion-proof bunker. – Matthew Roh – 2017-04-05T09:59:14.050