Created
May 10, 2015 23:01
-
-
Save drgarcia1986/9bb8581bbd8b648b9c03 to your computer and use it in GitHub Desktop.
Collection of CodinGame puzzles solved (http://www.codingame.com/)
This file contains 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
# game loop | |
while 1: | |
enemy1, dist1 = input(), int(input()) | |
enemy2, dist2 = input(), int(input()) | |
print(enemy1) if dist1 < dist2 else print(enemy2) |
This file contains 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
# LX: the X position of the light of power | |
# LY: the Y position of the light of power | |
# TX: Thor's starting X position | |
# TY: Thor's starting Y position | |
LX, LY, TX, TY = [int(i) for i in input().split()] | |
# game loop | |
while 1: | |
E = int(input()) | |
direction = '' | |
if LY > TY: | |
direction += 'S' | |
TY += 1 | |
elif LY < TY: | |
direction += 'N' | |
TY -= 1 | |
if LX > TX: | |
direction += 'E' | |
TX += 1 | |
elif LX < TX: | |
direction += 'W' | |
TX -= 1 | |
print(direction) |
This file contains 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
R = int(input()) # the length of the road before the gap. | |
G = int(input()) # the length of the gap. | |
L = int(input()) # the length of the landing platform. | |
if G >= 5: | |
max_speed = 7 | |
elif G >= 3: | |
max_speed = 5 | |
elif G >= 2: | |
max_speed = 3 | |
else: | |
max_speed = 2 | |
# game loop | |
while 1: | |
S = int(input()) # the motorbike's speed. | |
X = int(input()) # the position on the road of the motorbike. | |
if (X + S) >= R + 1: | |
print("JUMP") | |
while S > 0: | |
print("SLOW") | |
elif S == max_speed: | |
print("WAIT") | |
elif S > max_speed: | |
print("SLOW") | |
else: | |
print("SPEED") |
This file contains 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
while 1: | |
SX, SY = [int(i) for i in input().split()] | |
mp = [] | |
for i in range(8): | |
MH = int(input()) | |
if MH > 0: | |
mp.append( | |
{ | |
'position': i, | |
'height': MH | |
} | |
) | |
mp.sort(key=lambda d: d['height'], reverse=True) | |
next_fire = mp[0]['position'] | |
print('FIRE') if SX == next_fire else print('HOLD') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment