diff --git a/submittions/medium.py b/submittions/medium.py new file mode 100644 index 0000000..e2c626f --- /dev/null +++ b/submittions/medium.py @@ -0,0 +1,40 @@ +arr='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +def line_intersection(n,m,start,end): + s = [int(arr.index(start[0]))+1,int(start[1:])] # list of the start postiion with the format [a,b] where a and b are int + e = [int(arr.index(end[0]))+1,int(end[1:])] # .............. end ....... + if start == end: + return [end] + sol1 ,sol2 ='','' # two possible solutions max + + # making two line and finding the intersection between them (positive first) + solpx = (-s[1]+s[0]+e[1]+e[0])/2 + solpy = solpx+s[1]-s[0] + + if not solpx.is_integer(): + return ['no solution'] + + # check if they are on the board + if solpx>0 and solpx0 and solpy0 and solnx0 and solny