Created
August 17, 2016 11:29
-
-
Save dketov/ec1a596e1776512adb8915663b17c44d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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