Skip to content

Instantly share code, notes, and snippets.

@dketov
Created August 17, 2016 11:29
Show Gist options
  • Save dketov/ec1a596e1776512adb8915663b17c44d to your computer and use it in GitHub Desktop.
Save dketov/ec1a596e1776512adb8915663b17c44d to your computer and use it in GitHub Desktop.
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 "|"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment