Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Jolly
- Not jolly
- Python vs 2.7.9
- '''
- import sys
- test_cases = open(sys.argv[1], 'r')
- for test in test_cases:
- # ignore test if it is an empty line
- # 'test' represents the test case, do something with it
- # ...
- # ...
- nums = map(int , test.split())
- abs_diff = []
- if len(nums)==1:
- print "Jolly"
- else:
- for i in range(len(nums)-1):
- abs_diff.append(abs(nums[i]-nums[i+1]))
- #print abs_diff
- res = True
- for i in range(1,len(nums)):
- if i in abs_diff:
- res = res and True
- else:
- res = res and False
- if res:
- print "Jolly"
- else:
- print "Not jolly"
- test_cases.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement