brewersfan1976

remove_duplicate_characters.rb

May 24th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. def removeDuplicateCharacters(str)
  2.     string_length = str.length
  3.     x = 0
  4.     string = ""
  5.    
  6.     while (x < string_length)
  7.         if str.count(str[x]) == 1 then
  8.            string = string + str[x]
  9.         end
  10.            
  11.         x = x + 1
  12.     end
  13.        
  14.     return string
  15. end
Advertisement
Add Comment
Please, Sign In to add comment