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

Skip to content

Commit 00a677b

Browse files
author
Leo Silva Souza
committed
03/1 - Ruby
1 parent 74c601d commit 00a677b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2018/03_1/ruby/leovano.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
begin
4+
input = File.readlines(ARGV[0])
5+
rescue TypeError
6+
STDERR.puts 'Arg1'
7+
exit
8+
end
9+
10+
claims = Hash.new 0
11+
12+
input.map! do |claim|
13+
claim.split(/[#@,:x]/)
14+
.reject(&:empty?)
15+
.map(&:to_i)
16+
end
17+
18+
input.each do |claim|
19+
(claim[1]...claim[1] + claim[3]).each do |x|
20+
(claim[2]...claim[2] + claim[4]).each do |y|
21+
claims[[x, y]] += 1
22+
end
23+
end
24+
end
25+
26+
puts claims.values.count { |v| v > 1 }

0 commit comments

Comments
 (0)