Problem
This question actually came up at work today. We are planning an experiment where we will show a series of maps to users. Each map has 31 symbols on it. Each symbol also has a label. We noticed that, in a few cases, the labels overlapped, which rendered one of the labels unreadable.
We ended up identifying the problem symbols the old fashioned way--by looking at each map one by one and writing down the ID of any problem symbols we found--but I was thinking this problem could have been solved quite easily with an algorithm. It took about one man hour to visually check all the maps (using an admittedly clunky experiment data collection tool).
I'm curious how quickly people on this site could solve this problem, and I'm also interested in what kind of algorithms you come up with. (Note: this is not a homework question, although I think it would make an interesting homework or interview question.)
Specifications
- Maps: 24
- Map Size (pixels): 1024 X 768
- Symbols (circles) per map: 31
- Symbol Diameter (pixels): 60
Symbol coordinates are stored in a spreadsheet table (assume a tab-delimited text file) with the following columns:
MapId
(range: 1 - 24)SymbolId
(range: 1 - 744 (24 maps x 31 symbols/map = 744 total symbols)XCoordinate
(range: 0 - 1024)YCoordinate
(range: 0 - 768)
Assume all four columns contain integers
.
Goal
How fast can you come up with an algorithm (language of your choice) that:
- Reads in the tab-delimited text file that contains the input data.
- Determines, for each map, if any symbols overlap.
- If any symbols do overlap, reports which
SymbolId
s are in violation
Your answer should contain
- Your algorithm, which must satisfy all three goals (above).
- How long it took you to think of it and write it (you're on your honor). Note: you don't need to count the time it took you to read and understand the question, but once you start thinking of ideas for a solution, start the clock.
I'm not interested in how fast your algorithm runs or how efficient it is in its use of memory. I'm looking for a quick and dirty but accurate and reliable solution to the problem.