dketov
8/17/2016 - 11:29 AM

ships.py

ships=['a1c1', 'd3d7']
 
def fire(shot, ship):
  x, y = shot
  x1, y1, x2, y2 = ship
  return x1 <= x <= x2 and int(y1) <= int(y) <= int(y2)
 
print 20*"-"
for i in xrange(0,10):
        for j in xrange(0,10):
                shot = "%s%d" % (chr(ord('a')+j), i)
 
                if any(fire(shot, ship) for ship in ships):
                        print "#",
                else:
                        print " ",
        print "|"