diff options
| author | 冯昶 <seaker@qq.com> | 2021-03-15 18:18:09 +0800 |
|---|---|---|
| committer | 冯昶 <seaker@qq.com> | 2021-03-15 18:18:09 +0800 |
| commit | 5ed25077fde85262036c9db3e893d70ae0907b5c (patch) | |
| tree | 8932d25b3fa6076e2d91ab2a331d4d8bfff20544 /challenge-091/paulo-custodio/python/ch-2.py | |
| parent | 8b6be37fe4dac8b4c6489a95e55514b76b298d15 (diff) | |
| parent | 65d54d52500028ec5359a7d39619803ade281543 (diff) | |
| download | perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.gz perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.bz2 perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-091/paulo-custodio/python/ch-2.py')
| -rw-r--r-- | challenge-091/paulo-custodio/python/ch-2.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-091/paulo-custodio/python/ch-2.py b/challenge-091/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..84db6f66d8 --- /dev/null +++ b/challenge-091/paulo-custodio/python/ch-2.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# THE WEEKLY 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) |
