parent
25d32aa998
commit
a9f664f3f3
@ -1,4 +1,5 @@
|
|||||||
p ARGF.read.scan(/(\d+)-(\d+)\s*(\w):\s*(\w+)/)
|
day1 = proc {|min,max,char,pass| (min..max).cover?(pass.count(char)) }
|
||||||
|
day2 = proc {|p1,p2,char,pass| [pass[p1-1], pass[p2-1]].count(char) == 1 }
|
||||||
|
puts ARGF.read.scan(/^(\d+)-(\d+)\s*(\w):\s*(\w+)$/)
|
||||||
.map {|a,b,c,d| [a.to_i, b.to_i, c, d] }
|
.map {|a,b,c,d| [a.to_i, b.to_i, c, d] }
|
||||||
# .count {|min,max,char,pass| (min..max).cover?(pass.count(char)) }
|
.count(&day2)
|
||||||
.count {|p1,p2,char,pass| [pass[p1-1], pass[p2-1]].tally[char] == 1 }
|
|
||||||
|
Loading…
Reference in new issue