brewersfan1976

strange_code.rb

Mar 13th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.46 KB | None | 0 0
  1. def strangeCode(s, e)
  2.     first = true
  3.     string = ""
  4.     letter = 'a'
  5.    
  6.     while s < e - 1
  7.         s = s + 1
  8.         e = e - 1
  9.        
  10.         if first == true then
  11.            string = string + 'a'
  12.            first = false
  13.         elsif letter == 'a' then
  14.               string = string + 'b'
  15.               letter = 'b'
  16.         else
  17.               string = string + 'a'
  18.               letter = 'a'
  19.         end
  20.      end
  21.    
  22.     return string
  23.  end
Advertisement
Add Comment
Please, Sign In to add comment