Created
April 22, 2016 03:43
-
-
Save dukeimg/0bd5bc8320338d22fb4acee69b3b1d5b to your computer and use it in GitHub Desktop.
Skynet: the Chasm
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
STDOUT.sync = true # DO NOT REMOVE | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
@road = gets.to_i # the length of the road before the gap. | |
@gap = gets.to_i # the length of the gap. | |
@platform = gets.to_i # the length of the landing platform. | |
required_speed = @gap + 1 | |
# game loop | |
loop do | |
speed = gets.to_i # the motorbike's speed. | |
coord_x = gets.to_i # the position on the road of the motorbike. | |
# Write an action using puts | |
# To debug: STDERR.puts "Debug messages..." | |
action = "WAIT" | |
if speed < required_speed | |
action = "SPEED" | |
end | |
if speed > required_speed | |
action = "SLOW" | |
end | |
if (@road - coord_x) < speed | |
# Из-за огромной задержки приходтся | |
# рассчитывать оптимальный момент п | |
# рыжка отталкиваясь от скорости | |
action = "JUMP" | |
end | |
if coord_x >= @road + @gap | |
# Момент приземления | |
action = "SLOW" | |
end | |
# A single line containing one of 4 keywords: SPEED, SLOW, JUMP, WAIT. | |
puts action | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment