Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elevations = input()
- elevations = [int(i) for i in elevations if i != ' ']
- def transform(elevations):
- landscape = ['' for i in range(max(elevations))]
- for i in range(len(landscape)):
- for k in elevations:
- if len(landscape) - i > k:
- landscape[i] += ' '
- else:
- landscape[i] += 'X'
- return landscape
- def capacity(landscape):
- puddles = 0
- for i in range(len(landscape)):
- for k in range(len(landscape[i])//2):
- puddle = 'X' + ' ' * (k+1) + 'X'
- if landscape[i].find(puddle) != -1:
- puddles += k + 1 * landscape[i].count(puddle)
- else:
- continue
- return puddles
- print(capacity(transform(elevations)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement