I have tried the Kata below, but the execution is too slow, what can I do to make this script faster?
"Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements.
For example:
unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B']
unique_in_order('ABBCcAD') == ['A', 'B', 'C', 'c', 'A', 'D']
unique_in_order([1,2,2,3,3]) == [1,2,3]
def unique_in_order(iterable):
iterable = list(iterable)
while 1==1:
for x in range(len(iterable)):
if iterable[x]==iterable[x-1]:
del iterable[x]
break
if x==len(iterable)-1:
return iterable
test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('44444455321111'), ['4','5','3','2','1'])
test.assert_equals(unique_in_order('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCCCCCCCCCCCCCCDAABBB'), ['A','B','C','D','A','B'])
test.assert_equals(unique_in_order('AAAABBBCCCCCCCCCCCsssCCCCCCCCCCCCCDAABBB'), ['A','B','C','s', 'C','D','A','B'])