mirror of
https://github.com/mx42/codingame.git
synced 2026-01-14 05:39:51 +01:00
Adding easy puzzles
This commit is contained in:
24
puzzles/easy/the-descent.lua
Normal file
24
puzzles/easy/the-descent.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
-- https://www.codingame.com/ide/puzzle/the-descent
|
||||
-- Xavier Morel - 2016-03-12
|
||||
|
||||
-- Auto-generated code below aims at helping you parse
|
||||
-- the standard input according to the problem statement.
|
||||
|
||||
|
||||
-- game loop
|
||||
while true do
|
||||
v=0
|
||||
r=0
|
||||
for i=0,8-1 do
|
||||
mountainH = tonumber(io.read()) -- represents the height of one mountain, from 9 to 0.
|
||||
if mountainH > v then
|
||||
v = mountainH
|
||||
r = i
|
||||
end
|
||||
end
|
||||
|
||||
-- Write an action using print()
|
||||
-- To debug: io.stderr:write("Debug message\n")
|
||||
|
||||
print(r) -- The number of the mountain to fire on.
|
||||
end
|
||||
Reference in New Issue
Block a user