Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 92477f0 + e61a27f commit c6851e6Copy full SHA for c6851e6
2018/03_2/ruby/leovano.rb
@@ -0,0 +1,36 @@
1
+# frozen_string_literal: true
2
+
3
+begin
4
+ input = File.readlines(ARGV[0])
5
6
+ claims = Hash.new 0
7
8
+ input.map! do |claim|
9
+ claim.split(/[#@,:x]/)
10
+ .reject(&:empty?)
11
+ .map(&:to_i)
12
+ end
13
14
+ input.each do |claim|
15
+ (claim[1]...claim[1] + claim[3]).each do |x|
16
+ (claim[2]...claim[2] + claim[4]).each do |y|
17
+ claims[[x, y]] += 1
18
19
20
21
22
+ overlap = lambda do |claim|
23
24
25
+ return false if claims[[x, y]] != 1
26
27
28
+ true
29
30
31
+ puts input.find(&overlap)[0]
32
+rescue TypeError
33
+ STDERR.puts 'Arg1'
34
+rescue StandardError => e
35
+ STDERR.puts e
36
+end
0 commit comments