brewersfan1976

cool_string.rb

Jul 11th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.04 KB | None | 0 0
  1. def coolString(inputString)
  2.     string_length = inputString.length
  3.     x = 0
  4.    
  5.     if string_length == 1 then
  6.        if (inputString[x] >= 'A' and inputString[x] <= 'Z') or (inputString[x] >= 'a' and inputString[x] <= 'z') then
  7.            cool = true
  8.        else
  9.            return false
  10.        end
  11.     end
  12.        
  13.     if (inputString[string_length - 1] >= 'A' and inputString[string_length - 1] <= 'Z') or (inputString[string_length - 1] >= 'a' and inputString[string_length - 1] <= 'z') then
  14.         cool = true
  15.     else
  16.         return false
  17.     end
  18.        
  19.     while (x < string_length - 1)
  20.           if (inputString[x] >= 'A' and inputString[x] <= 'Z') or (inputString[x] >= 'a' and inputString[x] <= 'z') then
  21.              cool = true
  22.           else
  23.              return false
  24.           end
  25.              
  26.           if inputString[x] != inputString[x + 1] then
  27.              cool = true
  28.           else
  29.              return false
  30.           end
  31.                  
  32.           x = x + 1
  33.     end
  34.              
  35.     return true
  36. end
Advertisement
Add Comment
Please, Sign In to add comment