Closest-pair problem: Difference between revisions

Content added Content deleted
Line 211: Line 211:


=={{header|D}}==
=={{header|D}}==
D version 2 implementation, adapted from the Python version. This code is designed for compactness instead of performance.
D version 2 implementation, designed for compactness:
<lang d>import std.stdio,std.typecons,std.math,std.algorithm,std.array,std.random;
<lang d>import std.stdio,std.typecons,std.math,std.algorithm,std.array,std.random;


Line 288: Line 288:
Time gave 0:06.28 elapsed for brute force, and 0:00.07 elapsed for the divide & conquer one (10_000 points).
Time gave 0:06.28 elapsed for brute force, and 0:00.07 elapsed for the divide & conquer one (10_000 points).


A faster brute-force version:
A more efficient implementation of the brute-force algorithm:
<lang d>import std.stdio, std.typecons, std.math, std.random;
<lang d>import std.stdio, std.typecons, std.math, std.random;