You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
428 B
15 lines
428 B
11 months ago
|
patterns = ARGF.read.split("\n\n")
|
||
|
.map { _1.split("\n").map(&:chars) }
|
||
|
|
||
|
def find_fold(pattern)
|
||
|
(0.5...pattern.length-0.5).step(1).find {|fold|
|
||
|
a = pattern[0..fold.floor]
|
||
|
b = pattern[fold.ceil..]
|
||
|
a.reverse.zip(b).reject { _1.any?(&:nil?) }.all? { _1 == _2 }
|
||
|
}&.ceil
|
||
|
end
|
||
|
|
||
|
verts = patterns.map { find_fold(_1.transpose) }.compact
|
||
|
hors = patterns.map { find_fold(_1) }.compact
|
||
|
p verts.sum + hors.sum { _1 * 100 }
|