Daily Programmer Challenge #232: Where Should Grandma's House Go?

My submission to: https://www.reddit.com/r/dailyprogrammer/comments/3l61vx/20150916_challenge_232_intermediate_where_should/

by pendensproditor

HTML

<h1>Lot Coordinates</h1>
<pre id="lots">(5.558305599411531, 4.8600305440370475)
(7.817278884196744, 0.8355602049697197)
(0.9124479406145247, 9.989524754727917)
(8.30121530830896, 5.0088455259181615)
(3.8676289528099304, 2.7265254619302493)
(8.312363982415834, 6.428977658434681)
(2.0716308507467573, 4.39709962385545)
(4.121324567374094, 2.7272406843892005)
(9.545656436023116, 2.874375810978397)
(2.331392166597921, 0.7611494627499826)
(4.241235371900736, 5.54066919094827)
(3.521595862125549, 6.799892867281735)
(7.496600142701988, 9.617336260521792)
(2.5292596863427796, 4.6514954819640035)
(8.9365560770944, 8.089768281770253)
(8.342815293157892, 1.3117716484643926)
(6.358587371849396, 0.7548433481891659)
(1.9085858694489566, 1.2548184477302327)
(4.104650644200331, 5.1772760616934645)
(6.532092345214275, 8.25365480511137)
(1.4484096875115393, 4.389832854018496)
(9.685268864302843, 5.7247619715577915)
(7.277982280818066, 3.268128640986726)
(2.1556558331381104, 7.440500993648994)
(5.594320635675139, 6.636750073337665)
(2.960669091428545, 5.113509430176043)
(4.568135934707252, 8.89014754737183)
(4.911111477474849, 2.1025489963335673)
(8.756483469153423, 1.8018956531996244)
(1.2275680076218365, 4.523940697190396)
(4.290558055568554, 5.400885500781402)
(8.732488819663526, 8.356454134269345)
(6.180496817849347, 6.679672206972223)
(1.0980556346150605, 9.200474664842345)
(6.98003484966205, 8.22081445865494)
(1.3008030292739836, 2.3910813486547466)
(0.8176167873315643, 3.664910265751047)
(4.707575761419376, 8.48393210654012)
(2.574624846075059, 6.638825467263861)
(0.5055608733353167, 8.040212389937379)
(3.905281319431256, 6.158362777150526)
(6.517523776426172, 6.758027776767626)
(6.946135743246488, 2.245153765579998)
(6.797442280386309, 7.70803829544593)
(0.5188505776214936, 0.1909838711203915)
(7.896980640851306, 4.366680008699691)
(1.2404651962738256, 5.963706923183244)
(7.9085889544911945, 3.501907219426883)
(4.829123686370425, 6.116328436853205)
(8.703429477346157,...

CSS

body {
    padding: 10px 20px;
    font-family: monospace;
    font-size: 13px;
}

h1 {
    font-size: 17px;
}

pre {
    margin-bottom: 25px;
}

JavaScript

(function () {
    
    var parseCoordinates = function (str) {
            var strArr = str.match(/(-?\d*\.?\d+)/g),
                coordinates = [];

            for (var i = 0; i < strArr.length; i++) {
                coordinates.push(parseFloat(strArr[i]));
            }

            return coordinates;
        },
        
        gatherCoordinates = function () {
            var input = document.getElementById('lots').innerHTML,
                lines = input.split('\n'),
                lotLocations = [];

            for (var i = 0; i < lines.length; i++) {
                lotLocations.push(parseCoordinates(lines[i]));
            }

            return lotLocations;
        },

        getDistance = function (pair) {
            // To save on calculations we won't return the square
            // root of this, which is the true distance. We only
            // need to know which distance is shortest.
            return Math.pow(pair[0][0] - pair[1][0], 2) + Math.pow(pair[0][1] - pair[1][1], 2);
        },

        findClosestLots = function (lotLocations) {
            var shortestDistance,
            	shortestPair,
                distance,
                pair;

            // Test the distance of each coordinate without testing
            // the same two coordinates twice (in reverse order).
            for (var lotCount = lotLocations.length, i = 0; i < lotCount - 1; i++) {
                for (var j = i + 1; j < lotCount; j++) {
                    pair = [lotLocations[i], lotLocations[j]];
                    distance = getDistance(pair);

                    if (distance < shortestDistance || !shortestDistance) {
                        shortestDistance = distance;
                        shortestPair = pair;
                    }
                }
            }

            return shortestPair;
        };

    var closestLots = findClosestLots(gatherCoordinates());
    document.getElementById('output').innerHTML = '(' + closestLots[0].toString()...