Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from __future__ import division
- import collections
- import sys
- compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
- def main():
- initial = [3, 6, 5, 1, 9, 7, 2, 12, 23]
- expected = [2, 4, 3, 0, 6, 5, 1, 7, 8]
- for newMin in range(len(initial)):
- minIndex, minValue = 0, sys.maxint
- for i in range(len(initial)):
- currValue = initial[i]
- if currValue < minValue and currValue > newMin:
- minValue, minIndex = currValue, i
- initial[minIndex] = newMin
- print compare(initial, expected)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement