==== Quote ==== > Bill McKie pointed out that x86/OSX wasn't trapping overflows during > real exponentiation. It turns out that OSX uses the MMX unit to do > exponentiation instead of the x87. So I added code to set the bits for > MMX traps. Not only does the MMX exponentiation use about six times the > code that the x87 uses, but it turns out that OSX doesn't handle traps > from the MMX unit correctly either, reporting only a generic floating > point exception. To add insult to injury, it takes about 3/4 of second > (!) to process a floating point exception on OSX, be it x86 or powerpc. > > Over the last couple of years I've been coming around to a new > philosophy regarding OSX-- OSX sucks. Hard. ==== Problem ==== Given an arbitrary number of (min, max) pairs return all combinations of coordinate pairs. === Example 1 === Given {(0, 12), (1, 4)} and a length of 4 (where the length tells us how many steps to take along each (min, max) range, in this case we go from (0, 4, 8, 12), and (1, 2, 3, 4) both have length 4 and include the min and max) return: (0, 1) (0, 2) (0, 3) (0, 4) (4, 1) (4, 2) (4, 3) (4, 4) (8, 1) (8, 2) (8, 3) (8, 4) (12, 1) (12, 2) (12, 3) (12, 4) === Example 2 === grid([(1.0, 15.0), (1.0, 15.0), length=2) (1.0, 1.0) (1.0, 15.0) (15.0, 1.0) (15.0, 15.0) grid([(1.0, 15.0), (1.0, 15.0)], length=3) (1.0, 1.0) (1.0, 8.0) (1.0, 15.0) (8.0, 1.0) (8.0, 8.0) (8.0, 15.0) (15.0, 1.0) (15.0, 8.0) (15.0, 15.0) grid([(1.0, 15.0), (1.0, 15.0), length=4) (1.0, 1.0) (1.0, 5.666666666) (1.0, 10.33333333) (1.0, 15.0) (5.6666666, 1.0) (5.6666666, 5.6666666) (5.6666666, 10.333333) (5.6666666, 15.0) (10.333333, 1.0) (10.333333, 5.6666666) (10.333333, 10.333333) (10.333333, 15.0) (15.0, 1.0) (15.0, 5.6666666) (15.0, 10.333333) (15.0, 15.0) grid([(1.0, 15.0), (2.3, 17.4), (1.4, 21.0)], length=3) (1.0, 2.2999999999999998, 1.3999999999999999) (1.0, 2.2999999999999998, 11.200000000000001) (1.0, 2.2999999999999998, 21.0) (1.0, 9.8499999999999979, 1.3999999999999999) (1.0, 9.8499999999999979, 11.200000000000001) (1.0, 9.8499999999999979, 21.0) (1.0, 17.399999999999999, 1.3999999999999999) (1.0, 17.399999999999999, 11.200000000000001) (1.0, 17.399999999999999, 21.0) (8.0, 2.2999999999999998, 1.3999999999999999) (8.0, 2.2999999999999998, 11.200000000000001) (8.0, 2.2999999999999998, 21.0) (8.0, 9.8499999999999979, 1.3999999999999999) (8.0, 9.8499999999999979, 11.200000000000001) (8.0, 9.8499999999999979, 21.0) (8.0, 17.399999999999999, 1.3999999999999999) (8.0, 17.399999999999999, 11.200000000000001) (8.0, 17.399999999999999, 21.0) (15.0, 2.2999999999999998, 1.3999999999999999) (15.0, 2.2999999999999998, 11.200000000000001) (15.0, 2.2999999999999998, 21.0) (15.0, 9.8499999999999979, 1.3999999999999999) (15.0, 9.8499999999999979, 11.200000000000001) (15.0, 9.8499999999999979, 21.0) (15.0, 17.399999999999999, 1.3999999999999999) (15.0, 17.399999999999999, 11.200000000000001) (15.0, 17.399999999999999, 21.0) ==== Sollutions ==== * Josh - {{:codeapalooza:grid-0.2.tar|grid-0.2.tar}} (C) * Jason - {{:codeapalooza:grid.lisp.tar|grid.lisp.tar}} (Lisp) * Gabriel - {{:codeapalooza:grid.py.tar|grid.py.tar}} (Python)