indent-ruby-1

Write your program in Ruby which takes an un-indented Ruby code as string and outputs the indented Ruby code as string.

Input Format
A string which is un-indented Ruby code

Output Format
A string which is indented Ruby code

SAMPLE INPUT
class YabbaDabbaDoo
        def foo
        if foo == 42
        puts 'world hello'
          elsif foo == 24
          puts 'bk201'
        else
        puts 'congrats!'
          end
  end
end

SAMPLE OUTPUT
class YabbaDabbaDoo
 def foo
  if foo == 42
   puts 'world hello'
  elsif foo == 24
   puts 'bk201'
  else
   puts 'congrats!'
  end
 end
end

Explanation

Indentation is of 2 spaces.

Source: hackerearth | Difficulty: MEDIUM
Tags: Data structures

Ad-hoc


Solutions: