Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Drone stations You have a drone that can fly for a distance of D before it runs out of battery. There are N charging stations

Drone stations 

You have a drone that can fly for a distance of D before it runs out of battery. There are N charging stations that can fully charge up a drone. 

Write a program to determine whether there is a way to fly a drone (initially fully charged) from your location to a target location via zero or more intermediate charging stations.

 Input specification:

 The first line consists of two positive integers N (≤ 10) and D (≤ 10); where N is the number of charging stations, D is the distance that a fully charged drone can travel. The next N lines are the X-Y coordinates of the locations of the N charging stations. 

The 2nd last line is the X-Y coordinate of your location (with a fully charged drone).

 The last line is the X-Y coordinate of the target location. Output specification: The (lower-case) character “y” if there is a way to fly a drone (initially fully charged) from your location to a target location via zero or more intermediate charge stations., or “n” if there is not. 

Sample testcases (The bolded text are user input) 

Case 1

 3 7 

0 3 

5 1 

8 6 

0 1

 13 3

 y

 Case 2

 4 6

 1 7 

5 5 

6 1

 7 8 

5 6

 14 32

 n

Step by Step Solution

3.51 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

The following is the code of this question import math n... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Applied Corporate Finance

Authors: Aswath Damodaran

4th edition

978-1-118-9185, 9781118918562, 1118808932, 1118918568, 978-1118808931

More Books

Students also viewed these Programming questions

Question

Show that is one-to-one and find f(x) = J2 1 + 1 dt

Answered: 1 week ago

Question

4. I am able to influence decisions that affect my organization.

Answered: 1 week ago