# Common point puzzle

**URL:** <https://www.ruby-forum.com/t/common-point-puzzle/80058>\
**Category:** Ruby\
**Created:** [December 21, 2006, 2:31am UTC](https://www.ruby-forum.com/t/common-point-puzzle/80058 "2006-12-21T02:31:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [December 21, 2006, 2:31am UTC](https://www.ruby-forum.com/t/common-point-puzzle/80058/1 "2006-12-21T02:31:07Z")

</div>

Warning: the following really needs a sketch.

I have a series of three (x,y) grids with values, z,  
at each point. Each successive grid is twice as fine  
as the previous, i.e., dx1 = 2 \* dx2 = 4 \* dx3.

For a series of three nested grids, I’d like to compute  
(z2-z1)/(z3-z2) at each of the points shared between all  
three grids, i.e., at all the points of the coarsest grid.

The catch? The (x,y) points are not ordered in the same  
fashion for each grid. In other words, I need find the  
(x,y) coordinate shared by all three for each point in  
the coarsest grid.

Now, I can do this with a bunch of conditional checks,  
but I thought it might be possible to use Ruby’s set  
functions or Array intersection in some elegant way to  
create some sort of a mask that I could overlay the medium  
and fine grids with to find the coincident points.

Thanks for reading this far,

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [December 21, 2006, 3:15am UTC](https://www.ruby-forum.com/t/common-point-puzzle/80058/2 "2006-12-21T03:15:13Z")

</div>

Bil K. wrote:

> The catch? The (x,y) points are not ordered in the same  
> Thanks for reading this far,  
> Are these grids large enough that brute force in-core solutions are  
> ruled out? 🙂

–  
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)  
[http://borasky-research.blogspot.com/](http://borasky-research.blogspot.com/)

If God had meant for carrots to be eaten cooked, He would have given  
rabbits fire.

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [December 21, 2006, 3:57am UTC](https://www.ruby-forum.com/t/common-point-puzzle/80058/3 "2006-12-21T03:57:18Z")

</div>

Bil K. wrote:

> ## The catch? The (x,y) points are not ordered in the same Thanks for reading this far,
> 
> Bil K.  
> [http://fun3d.larc.nasa.gov](http://fun3d.larc.nasa.gov)

What is the layout of the array? Something like this?

[[x1,y1,z1], [x2,y2,z2] … ]
