blob: 538dce95f046504f3dfafbcea7c172c35b33ee73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env python
# Challenge 091
#
# TASK #2: Jump Game
#
# You are given an array of positive numbers @N, where value at each index
# determines how far you are allowed to jump further. Write a script to decide
# if you can jump to the last index. Print 1 if you are able to reach the last
# index otherwise 0.
import sys
n = [int(x) for x in sys.argv[1:]]
pos = 0
while pos < len(n)-1 and n[pos] != 0:
pos += n[pos]
if pos==len(n)-1:
print(1)
else:
print(0)
|