Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97063c5

Browse files
author
calypso
authored
Merge pull request#29 from leovano/leovano-052-ruby
05/2 - Ruby
2 parentsd0536f6 +d987a28 commit97063c5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎2018/05_2/ruby/ruby_2.rb‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
begin
4+
input=File.read(ARGV[0]).chomp
5+
6+
less=Float::INFINITY
7+
input.downcase.chars.uniq.eachdo |c|
8+
inputf=input.deletec +c.upcase
9+
10+
idx=0
11+
loopdo
12+
breakifidx ==inputf.size -1
13+
14+
ifinputf[idx] !=inputf[idx +1] &&
15+
inputf[idx].casecmp(inputf[idx +1]).zero?
16+
inputf.slice!idx..idx +1
17+
idx -=1ifidx.positive?
18+
else
19+
idx +=1
20+
end
21+
end
22+
23+
less=inputf.sizeifinputf.size <less
24+
end
25+
26+
putsless
27+
rescueTypeError
28+
STDERR.puts'Arg1'
29+
rescueStandardError=>e
30+
STDERR.putse
31+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp