## Closest Pair, Part 2

### February 13, 2015

We begin by noting that a point can be represented as an imaginary number, with its x-coordinate in the real part and its y-coordinate in the imaginary part, so that the distance between two points is just the magnitude of their difference. Thus:

```> (define p1 (make-rectangular 0 0)) > (define p2 (make-rectangular 1 1)) > (real-part p1) 0 > (imag-part p2) 1 > (magnitude (- p1 p2)) 1.4142135623730951```

Then we can generate a random set of points as in the previous exercise:

```(define max-coord 1000000)
(define infinity (* max-coord max-coord))

(define (rand-points n)
(define (r) (randint max-coord))
(do ((n n (- n 1))
(ps (list) (cons (make-rectangular (r) (r)) ps)))
((zero? n) ps)))```

Our first step is to rewrite the brute-force algorithm using the new representation:

```(define (brute-force-closest-pair ps)
(let ((min-dist infinity) (min-pair (list)))
(do ((ps ps (cdr ps))) ((null? (cdr ps)))
(do ((qs (cdr ps) (cdr qs))) ((null? qs))
(let ((d (magnitude (- (car ps) (car qs)))))
(when (< d min-dist)
(set! min-dist d)
(set! min-pair (cons (car ps) (list (car qs))))))))
(values min-dist min-pair)))```

The `closest-pair` function takes a list of points, then sorts them on their x-coordinates and again on their y-coordinates and passes the two lists of points to an auxiliary function:

```(define (closest-pair ps)
(closest-pair-aux
(sort (lambda (a b) (< (real-part a) (real-part b))) ps)
(sort (lambda (a b) (< (imag-part a) (imag-part b))) ps)))```

Now things get hard. If the list of points is small, we call the brute-force algorithm since it will be faster than all the recursive calls of the divide-and-conquer algorithm. Otherwise, we split the list of points in two on its x-coordinate, recursively find the closest pairs in the two pieces, then find the closest crossover pair:

```(define (closest-pair-aux xs ys)
(if (< (length xs) 10) (brute-force-closest-pair xs)
(let* ((len (length xs)) (mid (quotient len 2))
(x-left (take mid xs)) (x-right (drop mid xs))
(y-left (list-of p (p in ys)
(< (real-part p) (real-part (car x-right))))))
(y-right (list-of p (p in ys)
(>= (real-part p) (real-part (car x-right))))))
(let-values (((left-dist left-pair) (closest-pair-aux x-left y-left))
((right-dist right-pair) (closest-pair-aux x-right y-right)))
(let ((min-dist (if (< left-dist right-dist) left-dist right-dist))
(min-pair (if (< left-dist right-dist) left-pair right-pair)))
(let ((close-points (list-of p (p in ys)
(< (magnitude (- p (car x-right))) min-dist))))
(if (< (length close-points) 2) (values min-dist min-pair)
(let-values (((close-dist close-pair)
(brute-force-closest-pair close-points)))
(if (< min-dist close-dist)
(values min-dist min-pair)
(values close-dist close-pair))))))))))```

Let's look at that closely. The input lists are split on the midpoint: x-left and x-right are the left and right halves of the input list sorted on x-coordinate, and y-left and y-right are the left and right halves of the input list sorted on y-coordinate, with `(real-part (car x-right)) as the dividing x-coordinate. Then left-dist, left-pair and right-dist, right-pair are the minimums of the left and right halves, calculated recursively, and min-dist, min-pair is the minimum of the two halves.`

``` The remaining code calculates the minimum of the set of crossover pairs: close-points is the set of points within min-dist of the dividing x-coordinate, the minimum of that set of points is calculated using the brute-force algorithm, and replaces the previous minimum if it is smaller. Here are some examples: > (define ps (rand-points 1000)) > (time (call-with-values (lambda () (brute-force-closest-pair ps)) (lambda (min-dist min-pair) (display min-dist) (display " ") (display min-pair) (newline)))) 1088.9173522356966 (667333+162783i 666808+163737i) cpu time: 1727 real time: 1846 gc time: 390 > (time (call-with-values (lambda () (closest-pair ps)) (lambda (min-dist min-pair) (display min-dist) (display " ") (display min-pair) (newline)))) 1088.9173522356966 (666808+163737i 667333+162783i) cpu time: 46 real time: 49 gc time: 12 The results of the two algorithms are the same, even though the points appear in reverse order. The divide-and-conquer algorithm is very much faster than the brute-force algorithm. We used many functions from the Standard Prelude. It seems that codepad.org has lost the ability to save pastes, so the code is assembled on the next page. .wordads-ad-wrapper { display:none; font: normal 11px Arial, sans-serif; letter-spacing: 1px; text-decoration: none; width: 100%; margin: 25px auto; padding: 0; } .wordads-ad-title { margin-bottom: 5px; } .wordads-ad-controls { margin-top: 5px; text-align: right; } .wordads-ad-controls span { cursor: pointer; } .wordads-ad { width: fit-content; margin: 0 auto; } Advertisement sas.cmd.push(function() { sas.render("sas_110354"); }); window._stq = window._stq || []; window._stq.push( [ 'extra', { x_wordads_smart: 'render_sas_110354', }, ] ); Share this:TwitterFacebookLike this:Like Loading... Related Pages: 1 2 3 ```
``` Posted by programmingpraxis Filed in Exercises 2 Comments » ```
``` 2 Responses to “Closest Pair, Part 2” matthew said February 13, 2015 at 9:25 AM I was jumping the gun a bit with my solution to Part I. Do you use the fact that the ys list is sorted? Mike said February 15, 2015 at 11:10 PM from collections import namedtuple from itertools import combinations, product class Point(namedtuple("Point_", "x y")): def mag(self): return (self.x ** 2 + self.y ** 2) ** 0.5 def __sub__(self, other): return Point(self.x - other.x, self.y - other.y) def closest_pair2(points): def cp(ps): if len(ps) <= 3: d, pr = min(((p - q).mag(), (p, q)) for p,q in combinations(ps, 2)) else: m = len(ps) // 2 mid = ps[m] d, pr = min(cp(ps[:m]), cp(ps[m:])) for p in ps[m-1::-1]: if p.x < mid.x - d: break for q in ps[m:]: if q.x > p.x + d: break if p.y - d <= q.y <= p.y + d: td = (p - q).mag() if td < d: d = td pr = p, q return d, pr return cp(sorted(points)) Takes about 4.5 seconds to find closest pair in a set of 1000000 points–much faster than brute-force method. Example: >>> from random import randrange >>> from timeit import timeit >>> def random_point(a, b=None): return Point(randrange(a,b), randrange(a,b)) >>> points = set() >>> while len(points) < 1000000: points.add(random_point(5000000)) >>> timeit(stmt="print(closest_pair2(points))", setup="from __main__ import points, closest_pair2", number=1) (6.4031242374328485, (Point(x=185209, y=328746), Point(x=185214, y=328750))) 4.447064363699084 >>> Leave a Reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. ( Log Out /  Change ) You are commenting using your Twitter account. ( Log Out /  Change ) You are commenting using your Facebook account. ( Log Out /  Change ) Cancel Connecting to %s var highlander_expando_javascript = function () { function hide( sel ) { var el = document.querySelector( sel ); if ( el ) { el.style.setProperty( 'display', 'none' ); } } function show( sel ) { var el = document.querySelector( sel ); if ( el ) { el.style.removeProperty( 'display' ); } } var input = document.createElement( 'input' ); var comment = document.querySelector( '#comment' ); if ( input && comment && 'placeholder' in input ) { var label = document.querySelector( '.comment-textarea label' ); if ( label ) { var text = label.textContent; label.parentNode.removeChild( label ); comment.setAttribute( 'placeholder', text ); } } // Expando Mode: start small, then auto-resize on first click + text length hide( '#comment-form-identity' ); hide( '#comment-form-subscribe' ); hide( '#commentform .form-submit' ); if ( comment ) { comment.style.height = '10px'; var handler = function () { comment.style.height = HighlanderComments.initialHeight + 'px'; show( '#comment-form-identity' ); show( '#comment-form-subscribe' ); show( '#commentform .form-submit' ); HighlanderComments.resizeCallback(); comment.removeEventListener( 'focus', handler ); }; comment.addEventListener( 'focus', handler ); } } if ( document.readyState !== 'loading' ) { highlander_expando_javascript(); } else { document.addEventListener( 'DOMContentLoaded', highlander_expando_javascript ); } Notify me of new comments via email. Notify me of new posts via email. Δdocument.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); ```
``` Categories Administrivia Exercises Archives December 2021 November 2021 October 2021 September 2021 June 2021 May 2021 April 2021 March 2021 February 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 February 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 April 2019 March 2019 February 2019 January 2019 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 February 2015 S M T W T F S 1234567 891011121314 15161718192021 22232425262728 « Jan   Mar » Archives December 2021 November 2021 October 2021 September 2021 June 2021 May 2021 April 2021 March 2021 February 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 February 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 April 2019 March 2019 February 2019 January 2019 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 September 2017 August 2017 July 2017 June 2017 May 2017 April 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 August 2016 July 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 Blogroll WordPress.com WordPress.org ```
``` Create a free website or blog at WordPress.com. var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1\$s: You are commenting using your %2\$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"https:\/\/programmingpraxis.wordpress.com\/public.api\/connect\/?action=request&domain=programmingpraxis.com","logoutURL":"https:\/\/programmingpraxis.wordpress.com\/wp-login.php?action=logout&_wpnonce=e106cc5ae7","homeURL":"https:\/\/programmingpraxis.com\/","postID":"8319","gravDefault":"blank","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"","userIsLoggedIn":"","isJetpack":"","text_direction":"ltr"}; ( function () { var setupPrivacy = function() { // Minimal Mozilla Cookie library // https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework var cookieLib = window.cookieLib = {getItem:function(e){return e&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\\$&")+"\\s*\\=\\s*([^;]*).*\$)|^.*\$"),"\$1"))||null},setItem:function(e,o,n,t,r,i){if(!e||/^(?:expires|max\-age|path|domain|secure)\$/i.test(e))return!1;var c="";if(n)switch(n.constructor){case Number:c=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:c="; expires="+n;break;case Date:c="; expires="+n.toUTCString()}return"rootDomain"!==r&&".rootDomain"!==r||(r=(".rootDomain"===r?".":"")+document.location.hostname.split(".").slice(-2).join(".")),document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(o)+c+(r?"; domain="+r:"")+(t?"; path="+t:"")+(i?"; secure":""),!0}}; // Implement IAB USP API. window.__uspapi = function( command, version, callback ) { // Validate callback. if ( typeof callback !== 'function' ) { return; } // Validate the given command. if ( command !== 'getUSPData' || version !== 1 ) { callback( null, false ); return; } // Check for GPC. If set, override any stored cookie. if ( navigator.globalPrivacyControl ) { callback( { version: 1, uspString: '1YYN' }, true ); return; } // Check for cookie. var consent = cookieLib.getItem( 'usprivacy' ); // Invalid cookie. if ( null === consent ) { callback( null, false ); return; } // Everything checks out. Fire the provided callback with the consent data. callback( { version: 1, uspString: consent }, true ); }; // Initialization. document.addEventListener( 'DOMContentLoaded', function() { // Internal functions. var setDefaultOptInCookie = function() { var value = '1YNN'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 365 * 24 * 60 * 60, '/', domain ); }; var setDefaultOptOutCookie = function() { var value = '1YYN'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 24 * 60 * 60, '/', domain ); }; var setDefaultNotApplicableCookie = function() { var value = '1---'; var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'usprivacy', value, 24 * 60 * 60, '/', domain ); }; var setCcpaAppliesCookie = function( applies ) { var domain = '.wordpress.com' === location.hostname.slice( -14 ) ? '.rootDomain' : location.hostname; cookieLib.setItem( 'ccpa_applies', applies, 24 * 60 * 60, '/', domain ); } var maybeCallDoNotSellCallback = function() { if ( 'function' === typeof window.doNotSellCallback ) { return window.doNotSellCallback(); } return false; } // Look for usprivacy cookie first. var usprivacyCookie = cookieLib.getItem( 'usprivacy' ); // Found a usprivacy cookie. if ( null !== usprivacyCookie ) { // If the cookie indicates that CCPA does not apply, then bail. if ( '1---' === usprivacyCookie ) { return; } // CCPA applies, so call our callback to add Do Not Sell link to the page. maybeCallDoNotSellCallback(); // We're all done, no more processing needed. return; } // We don't have a usprivacy cookie, so check to see if we have a CCPA applies cookie. var ccpaCookie = cookieLib.getItem( 'ccpa_applies' ); // No CCPA applies cookie found, so we'll need to geolocate if this visitor is from California. // This needs to happen client side because we do not have region geo data in our \$SERVER headers, // only country data -- therefore we can't vary cache on the region. if ( null === ccpaCookie ) { var request = new XMLHttpRequest(); request.open( 'GET', 'https://public-api.wordpress.com/geo/', true ); request.onreadystatechange = function () { if ( 4 === this.readyState ) { if ( 200 === this.status ) { // Got a geo response. Parse out the region data. var data = JSON.parse( this.response ); var region = data.region ? data.region.toLowerCase() : ''; var ccpa_applies = ['california', 'colorado', 'connecticut', 'utah', 'virginia'].indexOf( region ) > -1; // Set CCPA applies cookie. This keeps us from having to make a geo request too frequently. setCcpaAppliesCookie( ccpa_applies ); // Check if CCPA applies to set the proper usprivacy cookie. if ( ccpa_applies ) { if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } else { // CCPA does not apply. setDefaultNotApplicableCookie(); } } else { // Could not geo, so let's assume for now that CCPA applies to be safe. setCcpaAppliesCookie( true ); if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } } }; // Send the geo request. request.send(); } else { // We found a CCPA applies cookie. if ( ccpaCookie === 'true' ) { if ( maybeCallDoNotSellCallback() ) { // Do Not Sell link added, so set default opt-in. setDefaultOptInCookie(); } else { // Failed showing Do Not Sell link as required, so default to opt-OUT just to be safe. setDefaultOptOutCookie(); } } else { // CCPA does not apply. setDefaultNotApplicableCookie(); } } } ); }; // Kickoff initialization. if ( window.defQueue && defQueue.isLOHP && defQueue.isLOHP === 2020 ) { defQueue.items.push( setupPrivacy ); } else { setupPrivacy(); } } )(); Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy ( function() { function init() { document.body.addEventListener( 'is.post-load', function() { if ( typeof __ATA.insertInlineAds === 'function' ) { __ATA.insertInlineAds(); } } ); } if ( document.readyState !== 'loading' ) { init(); } else { document.addEventListener( 'DOMContentLoaded', init ); } } )(); Follow Following Programming Praxis Join 824 other followers Already have a WordPress.com account? Log in now. Programming Praxis Customize Follow Following Sign up Log in Copy shortlink Report this content View post in Reader Manage subscriptions Collapse this bar window.addEventListener( "load", function( event ) { var link = document.createElement( "link" ); link.href = "https://s0.wp.com/wp-content/mu-plugins/actionbar/actionbar.css?v=20210915"; link.type = "text/css"; link.rel = "stylesheet"; document.head.appendChild( link ); var script = document.createElement( "script" ); script.src = "https://s0.wp.com/wp-content/mu-plugins/actionbar/actionbar.js?v=20220329"; script.defer = true; document.body.appendChild( script ); } ); window.WPCOM_sharing_counts = {"https:\/\/programmingpraxis.com\/2015\/02\/13\/closest-pair-part-2\/":8319}; (function(){ var corecss = document.createElement('link'); var themecss = document.createElement('link'); var corecssurl = "https://s1.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/styles/shCore.css?ver=3.0.9b"; if ( corecss.setAttribute ) { corecss.setAttribute( "rel", "stylesheet" ); corecss.setAttribute( "type", "text/css" ); corecss.setAttribute( "href", corecssurl ); } else { corecss.rel = "stylesheet"; corecss.href = corecssurl; } document.head.appendChild( corecss ); var themecssurl = "https://s2.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/styles/shThemeDefault.css?m=1363304414h&amp;ver=3.0.9b"; if ( themecss.setAttribute ) { themecss.setAttribute( "rel", "stylesheet" ); themecss.setAttribute( "type", "text/css" ); themecss.setAttribute( "href", themecssurl ); } else { themecss.rel = "stylesheet"; themecss.href = themecssurl; } document.head.appendChild( themecss ); })(); SyntaxHighlighter.config.strings.expandSource = '+ expand source'; SyntaxHighlighter.config.strings.help = '?'; SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n'; SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: '; SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: '; SyntaxHighlighter.defaults['pad-line-numbers'] = false; SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); // Infinite scroll support if ( typeof( jQuery ) !== 'undefined' ) { jQuery( function( \$ ) { \$( document.body ).on( 'post-load', function() { SyntaxHighlighter.highlight(); } ); } ); } var sharing_js_options = {"lang":"en","counts":"1","is_stats_active":"1"}; var windowOpen; ( function () { function matches( el, sel ) { return !! ( el.matches && el.matches( sel ) || el.msMatchesSelector && el.msMatchesSelector( sel ) ); } document.body.addEventListener( 'click', function ( event ) { if ( ! event.target ) { return; } var el; if ( matches( event.target, 'a.share-twitter' ) ) { el = event.target; } else if ( event.target.parentNode && matches( event.target.parentNode, 'a.share-twitter' ) ) { el = event.target.parentNode; } if ( el ) { event.preventDefault(); // If there's another sharing window open, close it. if ( typeof windowOpen !== 'undefined' ) { windowOpen.close(); } windowOpen = window.open( el.getAttribute( 'href' ), 'wpcomtwitter', 'menubar=1,resizable=1,width=600,height=350' ); return false; } } ); } )(); var windowOpen; ( function () { function matches( el, sel ) { return !! ( el.matches && el.matches( sel ) || el.msMatchesSelector && el.msMatchesSelector( sel ) ); } document.body.addEventListener( 'click', function ( event ) { if ( ! event.target ) { return; } var el; if ( matches( event.target, 'a.share-facebook' ) ) { el = event.target; } else if ( event.target.parentNode && matches( event.target.parentNode, 'a.share-facebook' ) ) { el = event.target.parentNode; } if ( el ) { event.preventDefault(); // If there's another sharing window open, close it. if ( typeof windowOpen !== 'undefined' ) { windowOpen.close(); } windowOpen = window.open( el.getAttribute( 'href' ), 'wpcomfacebook', 'menubar=1,resizable=1,width=600,height=400' ); return false; } } ); } )(); // <![CDATA[ (function() { try{ if ( window.external &&'msIsSiteMode' in window.external) { if (window.external.msIsSiteMode()) { var jl = document.createElement('script'); jl.type='text/javascript'; jl.async=true; jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jl, s); } } }catch(e){} })(); // ]]> %d bloggers like this: _tkq = window._tkq || []; _stq = window._stq || []; _tkq.push(['storeContext', {'blog_id':'6649073','blog_tz':'0','user_lang':'en','blog_lang':'en','user_id':'0'}]); _stq.push(['view', {'blog':'6649073','v':'wpcom','tz':'0','user_id':'0','post':'8319','subd':'programmingpraxis'}]); _stq.push(['extra', {'crypt':'UE5XaGUuOTlwaD85flAmcm1mcmZsaDhkV11YdWtpP0NsWnVkPS9sL0ViLndld3BuVT01Uj14Ti1yYTBnR1N+UVJ+VkxET2R3R0Y/YTloT0RYa2kuUFZSTmFVV1p+K2s4QVNIMlBNPTV8LC5QdEQmPWUmdmljRlIsVzlUOVpdNS9wUVAuMW1JaEF8bzV3NyZoUkNmSTN3eGQ3YXJRLVVqamJ6YSUyTUJKSVU9WFAxUndWbSsxQ1IrTEhiRV8xcWpEJkVFMFl6RFtPamxhWFs3XXc1NnN5TXVIVHd+VVhma0hCYUpvRXgtZUdnT0dSaHFNVHhDdWh1aHBdZXYmOExWX3NEcXJ3PXlXXUt3SHFzSVFfdm0yeV9iWV1wZG8wST0ubjl3fi4rdlQ2XzI9N1tiZH50cUFWZnd6PUQ/Qi1DcTZ0JkVJTEdHbkczWC0zLk8zR0VjbCx0Q1B8TWNZVH5tVHJwfldXMUhLX3VY'}]); _stq.push([ 'clickTrackerInit', '6649073', '8319' ]); if ( 'object' === typeof wpcom_mobile_user_agent_info ) { wpcom_mobile_user_agent_info.init(); var mobileStatsQueryString = ""; if( false !== wpcom_mobile_user_agent_info.matchedPlatformName ) mobileStatsQueryString += "&x_" + 'mobile_platforms' + '=' + wpcom_mobile_user_agent_info.matchedPlatformName; if( false !== wpcom_mobile_user_agent_info.matchedUserAgentName ) mobileStatsQueryString += "&x_" + 'mobile_devices' + '=' + wpcom_mobile_user_agent_info.matchedUserAgentName; if( wpcom_mobile_user_agent_info.isIPad() ) mobileStatsQueryString += "&x_" + 'ipad_views' + '=' + 'views'; if( "" != mobileStatsQueryString ) { new Image().src = document.location.protocol + '//pixel.wp.com/g.gif?v=wpcom-no-pv' + mobileStatsQueryString + '&baba=' + Math.random(); } } ```