SHARE
TWEET

Untitled

a guest Feb 15th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def swap(arr, l, r):
  2.     tmp = arr[l]
  3.     arr[l] = arr[r]
  4.     arr[r] = tmp
  5.  
  6. def bucketDucket(ducks):
  7.     n = len(ducks)
  8.     C = 0
  9.     R = 0
  10.  
  11.     for i in range(n):
  12.         if ducks[i] == 'L':
  13.             swap(ducks, R, i)
  14.             swap(ducks, C, R)
  15.             R += 1
  16.             C += 1
  17.         elif ducks[i] == 'C':
  18.             swap(ducks, R, i)
  19.             R +=1
  20.         else:
  21.             pass
  22.     return ducks
  23.  
  24. print(bucketDucket(list('RRLLCC')))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top