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

Commitc6851e6

Browse files
author
calypso
authored
03/2 - Ruby
03/2 - Ruby
2 parents92477f0 +e61a27f commitc6851e6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎2018/03_2/ruby/leovano.rb‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
begin
4+
input=File.readlines(ARGV[0])
5+
6+
claims=Hash.new0
7+
8+
input.map!do |claim|
9+
claim.split(/[#@,:x]/)
10+
.reject(&:empty?)
11+
.map(&:to_i)
12+
end
13+
14+
input.eachdo |claim|
15+
(claim[1]...claim[1] +claim[3]).eachdo |x|
16+
(claim[2]...claim[2] +claim[4]).eachdo |y|
17+
claims[[x,y]] +=1
18+
end
19+
end
20+
end
21+
22+
overlap=lambdado |claim|
23+
(claim[1]...claim[1] +claim[3]).eachdo |x|
24+
(claim[2]...claim[2] +claim[4]).eachdo |y|
25+
returnfalseifclaims[[x,y]] !=1
26+
end
27+
end
28+
true
29+
end
30+
31+
putsinput.find(&overlap)[0]
32+
rescueTypeError
33+
STDERR.puts'Arg1'
34+
rescueStandardError=>e
35+
STDERR.putse
36+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp