Guest User

Untitled

a guest
Jan 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def RGB(x):
  2. colors={'R','G','B'} #총 컬러 수
  3. result=[] #
  4. if len(x)==1:
  5. return x
  6. else:
  7. for i in range(len(x)-1):
  8. if x[i]==x[i+1]:
  9. result.append(x[i])
  10. else:
  11. input_colors={x[i],x[i+1]}
  12. output_colors=colors-input_colors
  13. result.append(list(output_colors)[0])
  14. return RGB(''.join(result))
  15.  
  16. print(RGB('RRR'))
  17. print(RGB('RB'))
  18. print(RGB('RG'))
  19. print(RGB('RRRGGGBBBBBB'))
  20. print(RGB('RRGBRGBB'))
Add Comment
Please, Sign In to add comment