Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b51e8f

Browse files
author
Leo Silva Souza
committed
05/1 - Ruby
1 parent 74c601d commit 6b51e8f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

2018/05_1/ruby/leovano.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
begin
4+
input = File.read(ARGV[0]).chomp
5+
6+
idx = 0
7+
loop do
8+
break if idx == input.size - 1
9+
10+
if input[idx] != input[idx + 1] && input[idx].casecmp(input[idx + 1]).zero?
11+
input.slice! idx..idx + 1
12+
idx -= 1
13+
else
14+
idx += 1
15+
end
16+
end
17+
18+
puts input
19+
rescue TypeError
20+
STDERR.puts 'Arg1'
21+
rescue StandardError => e
22+
STDERR.puts e
23+
end

0 commit comments

Comments
 (0)