If 2 - Challenges

Treasure Island

While reading ancient manuscripts you discovered there is an island in the pacific where incredible treasures are buried. In the manuscripts there is a map, and the zones where the gold could be are marked in green. You can ignore the other colors. You send in a drone which can land and drill the terrain. Strong winds and various factors could move the drone away from the target, so the drone at every moment needs to know whether or not is on a zone it should drill.

Write some code which given the map side length d and two coordinates x and y, RETURN True if the place is to drill (that is, the drone is on a green zone), otherwise return False.

ASSUME THAT THE ORIGIN (0,0) IS AT THE CENTRE OF THE MAP

treasure-island.png

[1]:

import math

d = 10
x,y = 0,0              # True
#x,y = 0.2*d,0         # True
#x,y = 0,0.1*d         # True
#x,y = 0,-0.03*d       # True
#x,y = -0.01*d,-d*0.05 # True
# corona
#x,y = 0,-0.3*d        # False
#x,y = 0.35*d,0        # False
#x,y = 0.4*d,0.27*d    # False
#x,y = 0.31*d,-0.4*d   # False
#x,y = -0.31*d,0.4*d   # False
#x,y = -0.3*d,-0.38*d  # False
# corners
#x,y = 0.49*d,0.49*d   # True
#x,y = 0.45*d,-0.46*d  # False
#x,y = -0.48*d,0.45*d  # False
#x,y = -0.49*d,-0.47*d # True

# write here