Created
March 9, 2015 15:27
-
-
Save ColinDKelley/fd97b73e9ef8772e1a7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tiles = {} | |
STDIN.readlines.map.with_index do |line, y| | |
x = 0 | |
line.chomp.split(".").each do |segment| | |
unless segment.empty? | |
tile = [x, segment.size, segment[0]] | |
if value = tiles[tile] | |
tiles[tile] = [value.first, value.last + 1] | |
else | |
tiles[tile] = [y, 1] | |
end | |
end | |
x += segment.size + 1 | |
end | |
end | |
tiles.sort_by { |(x, _, _), (y, _)| [x, y] }.each do |(x, width, character), (y, height)| | |
puts "(#{width}x#{height}) tile of character '#{character}' located at (#{x},#{y})" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment