Guest User

Untitled

a guest
Mar 31st, 2020
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. fun(input: String): String{
  3. var current: Char = input[0]
  4. var count: Int = 1
  5. val result: String = ""
  6. for(i in range(input.length-1)){
  7. if(input[i] == input[i+1]){
  8. current = input[i+1]
  9. count = count+1
  10. }else{
  11. if(count > 1){
  12. result = result + "${count}"
  13. }
  14. count = 1
  15. result = result + "${current}"
  16.  
  17. }
  18. current = input[i+1]
  19. }
  20. return result
  21. }
RAW Paste Data