# What are the most worthless subway stations in New York?

I was recently riding on the subway and it ocurred to me that some stations are much, much closer together than is typical. You can ride 30 blocks from West 42nd Street to West 72nd in a straight shot on the 2 or 3 lines, or 39 blocks between East 86th Street to East 125th Street on the 4 or the 5, but then sometimes you’re stuck mosying along between 110th and 116th, or between 14th and 18th. I heard a comedian make a joke about the pointlessness of stations four blocks apart, years ago. Nobody laughed, but I think he was onto something — some of these stops are very close together.

But how close? Scads of GIS files about New York City are freely available, and Mathematica has had the native ability to deal with these since version 7, though I’ve never used these functions. Let’s see what we can find out about the New York City Subways.

I used borough outlines from http://www.baruch.cuny.edu/geoportal/data/nymag/ and subway entrance locations from http://mta.info/developers/sbwy_entrance.html. I found three potentially tricky elements to the calculation \[LongDash] first, the subway entrances are not necessarily centered around their respective subway platforms; I chose a single entrance arbitrarily for each station but if I chose an outlying one, it will introduce a small error in my result. Second, the subway entrace locations are in {latitude,longitude} format (actually, {latitude,longitude}*1,000,000), and this is the format expected by Mathematica’s GeoDistance[] function, but the basemap is formated in {longitude, latitude} format, so we have to reverse the order of the elements in each location when we switch between mapping and determining distances. Third, the city’s database of subway entrances identifies an entrance as pertaining to a given line even if it is connected to that line only by an underground pedestrian tunnel. Since we care about what the trains are doing only, these have to be screened out by hand.

`stations = Import[NotebookDirectory[] <> "StationEntrances.csv"];`

``` ```

```allLines = Union[Flatten[Drop[stations, 1][[All, Range[4, 14]]]]]; allLines = Select[allLines, # != "" &]; index = Table[{i, allLines[[i]]}, {i, 1, Length[allLines]}]; ```
This function lets us extract all subway stations pertaining to a given line.

```matchLine[line_] := Union[Select[ Drop[stations, 1], #[[4]] == line || #[[5]] == line || #[[6]] == line || #[[7]] == line || #[[8]] == line || #[[9]] == line || #[[10]] == line || #[[11]] == line || #[[12]] == line || #[[13]] == line || #[[14]] == line &], SameTest -> (#1[[3]] == #2[[3]] &)]```

``` ```

`byLineUnique = Map[matchLine[#] &, allLines];`

Let’s graph it to see if this looks reasonable. Note that I specify the PlotRange to eliminate Staten Island, which has no subways.
``` bg = Import[NotebookDirectory[] <> "nymag_nyc_geog/nyc_pumas_2008.shp"];```

``` ```

```Show[bg, Graphics[{PointSize[Medium], Red, Point@(Map[Reverse, Drop[stations[[All, {25, 26}]], 1]/1000000.])}], PlotRange -> {{-74.05(*w*), -73.69(*e*)}, {40.54(*s*), 40.92(*n*)}}]```

Subway entrances as rendered by Mathematica

Looks good to me. We could easily graph each line in a difference color, connect the dots with lines, etc., but this will do for now.

The station entrance data includes all sorts of things we don’t care about, so let’s simplify it.

```vitalTable = Table[{index[[i]][[2]], Map[{#[[3]], {#[[26]], #[[25]]}/10^6} &, byLineUnique[[i]]] // N}, {i, 1, Length[byLineUnique]}];```

For the moment I don’t care about the order the stations are in, I’m going to check every station against every other one.

```vitalDistances = Table[{index[[i]][[2]], SortBy[Union[ Map[{#[[All, 1]], Round[GeoDistance[Reverse[#[[1]][[2]]], Reverse[#[[2]][[2]]]], .1]} &, Permutations[vitalTable[[i]][[2]], {2}]]], Last]}, {i, 1, Length[byLineUnique]}];```

Below is a list of subway stations combinations that aren’t traversed by the trains themselves and therefore shouldn’t be counted as “too close”. We’ll screen these out.

```disallowedCombos = {{"14 St", "6 Av"}, {"South Ferry", "Whitehall St-South Ferry"}, {"Chambers St", "Park Place"}, {"Atlantic Av", "Atlantic Av-Pacific St"}, {"Brooklyn Bridge-City Hall", "Chambers St"}, {"Franklin Av", "Botanic Garden"}, {"Botanic Garden", "Franklin Av"}, {"59 St", "Lexington Av/59 St"}, {"51 St", "Lexington Av/53 St"}, {"74 St-Broadway", "Jackson Heights-Roosevelt Av"}, {"14 St", "8 Av"}, {"62 St", "New Utrecht Av"}, {"Park Place", "World Trade Center"}, {"42 St-Bryant Pk", "5 Av"}, {"Lorimer St", "Metropolitan Av"}, {"Court Sq", "Court Sq-23 St"}, {"42 St-Port Authority Bus Terminal", "Times Sq-42 St"}, {"Chambers St", "World Trade Center"}, {"Borough Hall", "Court St"}};```

``` screenedVitalDistances = Table[{index[[i]][[2]], Select[SortBy[ Union[vitalDistances[[i]][[2]], SameTest -> (#1[[1]] == Reverse[#2[[1]]] &)], Last], ! MemberQ[disallowedCombos, #[[1]]] &]}, {i, 1, Length[byLineUnique]}]; ```

``` Map[{#[[1]], First[#[[2]]][[1]], First[#[[2]]][[2]], Last[#[[2]]][[1]], Last[#[[2]]][[2]]} &, screenedVitalDistances]```

The stations closest to each other and farthest from each other for each subway line in New York.

In the next post, I will demonstrate an interactive tool (which I have also uploaded to the Wolfram Demonstrations Project) that shows all the stations for a given line, marking the closest ones in green and the farthest ones in red, with tooltips identifying every station.

# A perfect solution to 24s

In several recent posts, I have discussed a method for perfect solution to the game of 24s. Here, I summarize some of those results and link to the Mathematica notebook I used to find them, and a comprehensive list of solutions for those who would like to skip the math and get right to the answer.

To recap, there are 715 possible hands in a game of 24s. 566 of those hands can be solved with arithmetics alone, 595 if we add roots, powers, and logs, and 619 if we add Mod.

I generally play with Log and Power and Root allowed, but not Mod. I find that the hands that are solvable only with Log, Power, and Root, generally are solvable by humans. See for example

{1,1,8,9} -> 8 Root[9,1+1]
{1,2,9,9} -> (9-1) Root[9,2]
{2, 2, 2, 6} -> 2^(2+Log[2,6]) or (2*Root[6,2])^2
{2,2,9,9} -> 2(Root[9,2]+9)
{3,7,8,10} -> 7 Root[8,3] +10
{3,4,9,10} -> 4+Log[3,9]*10
{7, 8, 9, 9} -> 8 Root[9,9-7], and
{8, 8, 9, 10} -> 8 Root[9,10-8].

A bright high school student should be able to find any of those. However, Mod introduces solutions that would probably never be played by an unaided human being. For example,

{5, 6, 7, 10} -> 6*Mod[7^10,5], and

{5,7,7,8} -> 8*Mod[7^7,5].

There is no other solution in these two cases.

Anyway, I’ve provided a comprehensive list of solutions linked as RTF and PDF documents, and the Mathematica notebook that I used to solve the problem in the first place.

And, most importantly, the Mathematica notebook.

Let me know if you do anything interesting with this.

# Solving 24s, part iii: mod

I have shown how to comprehensively solve a game of 24s that allows just arithmetic, and how to expand that to allow powers, roots, and logarithms. Now we’re going to add the modulo (Mod) function.

If you’ve followed the methodology in parts i and ii, this is pretty simple stuff.

First, to our set of simplified function definitions, I add
```mod[x_Integer?(# > 0 &), y_Integer?(-16 <= # <= 16 && # != 0 &)] := Mod[x, y]; mod[x__] := Indeterminate;```

Then, our rule definition step looks like
`rules = generateRules[{Times, Plus, Subtract, divide, power, root, log, mod}, 4];`

We're up to 512 rules here, once redundant patterns are eliminated. The complexity increases exponentially with the number of operators allowed.

The good news is that Mod makes lots of hands solvable that wouldn't be otherwise. See, for example,

{3, 5, 5, 10} -> 5*5-Mod[10,3]
{5, 6, 7, 10} -> 6*Mod[7^10,5]
{5, 7, 7, 8} -> Mod[7^7,5]*8, and
{6, 7, 7, 9} -> 6*Mod[7*7,9]

In fact, allowing Mod as an operator increases the total number of solvable hands all the way to 619 out of 715.

The unsolvable hands that remain are
{{1, 1, 1, 1}, {1, 1, 1, 2}, {1, 1, 1, 3}, {1, 1, 1, 4}, {1, 1, 1, 6}, {1, 1, 1, 7}, {1, 1, 1, 9}, {1, 1, 1, 10}, {1, 1, 2, 2}, {1, 1, 2, 3}, {1, 1, 5, 9}, {1, 1, 5, 10}, {1, 1, 6, 7}, {1, 1, 6, 10}, {1, 1, 7, 7}, {1, 1, 7, 8}, {1, 1, 7, 9}, {1, 1, 8, 10}, {1, 1, 9, 9}, {1, 1, 9, 10}, {1, 1, 10, 10}, {1, 2, 2, 2}, {1, 2, 9, 10}, {1, 2, 10, 10}, {1, 4, 9, 9}, {1, 5, 7, 7}, {1, 6, 6, 7}, {1, 6, 7, 7}, {1, 6, 7, 8}, {1, 6, 10, 10}, {1, 7, 7, 7}, {1, 7, 7, 8}, {1, 7, 10, 10}, {1, 8, 9, 9}, {1, 8, 9, 10}, {1, 8, 10, 10}, {1, 9, 9, 9}, {1, 9, 9, 10}, {1, 9, 10, 10}, {1, 10, 10, 10}, {2, 2, 2, 2}, {2, 2, 7, 9}, {2, 6, 7, 7}, {2, 7, 7, 7}, {2, 7, 7, 9}, {2, 7, 9, 9}, {2, 9, 9, 9}, {2, 9, 9, 10}, {2, 10, 10, 10}, {3, 3, 10, 10}, {3, 5, 7, 7}, {3, 10, 10, 10}, {4, 4, 9, 9}, {4, 7, 7, 9}, {4, 7, 7, 10}, {4, 9, 9, 9}, {5, 5, 5, 7}, {5, 5, 5, 8}, {5, 5, 5, 10}, {5, 5, 6, 10}, {5, 5, 7, 9}, {5, 7, 7, 7}, {5, 7, 9, 9}, {5, 8, 10, 10}, {5, 9, 9, 9}, {5, 10, 10, 10}, {6, 6, 6, 7}, {6, 6, 7, 7}, {6, 6, 7, 8}, {6, 7, 7, 7}, {6, 7, 7, 8}, {6, 9, 10, 10}, {7, 7, 7, 7}, {7, 7, 7, 8}, {7, 7, 7, 9}, {7, 7, 7, 10}, {7, 7, 8, 8}, {7, 7, 8, 9}, {7, 7, 9, 9}, {7, 8, 8, 8}, {7, 9, 9, 9}, {7, 9, 9, 10}, {7, 9, 10, 10}, {7, 10, 10, 10}, {8, 8, 8, 8}, {8, 8, 9, 9}, {8, 8, 10, 10}, {8, 9, 9, 9}, {8, 9, 9, 10}, {8, 9, 10, 10}, {8, 10, 10, 10}, {9, 9, 9, 9}, {9, 9, 9, 10}, {9, 9, 10, 10}, {9, 10, 10, 10}, {10, 10, 10, 10}}

# Solving 24s, part ii: powers, roots, and logarithms

In my last post on this topic, I showed that 566 of 715 possible hands in the game of 24s could be solved with simple arithmetic. However in practice people don’t play with just those operators. In my experience, a normal game always includes powers, roots, and logarithms. The solution method used for arithmetics works just fine when expanded for these additional functions, though I chose to make some small modifications for the sake of efficiency.

First, I redefine the functions to remove some cases that are quite unlikely to produce 24s, and which would increase memory needs and processing time significantly if left in place. See the following, for example:

``` Off[General::"spell1"]; Off[General::"spell"]; power[x_?(# > 0 &), y_?(-16 <= # <= 16 &)] := x^y; power[x__] := Indeterminate; root[x_Integer?(# > 0 &), y_Integer?(-16 <= # <= 16 && # != 0 &)] := Power[x, (y)^-1]; root[x__] := Indeterminate; divide[x_, y_] /; y != 0 := Divide[x, y]; divide[x_, 0] := Indeterminate; log[x_?(# > 0 &), y_?(# > 0 &)] := Log[x, y]; log[x__] := Indeterminate; ```

We can then generate rules as in the arithmetic case but with

`rules = generateRules[{Times, Plus, Subtract, divide, power, root, log}, 4];`

and run legitCombos as before. The result? 595 hands are solvable, as opposed to the 566 we had before. hands that can be solved now, that couldn’t be solved before, include

{1,1,8,9} -> 8 Root[9,1+1] and trivial variations
{1,2,9,9} -> (9-1) Root[9,2] and trivial variations
{2, 2, 2, 6} -> 2^(2+Log[2,6]) or (2*Root[6,2])^2 and trivial variations
{2,2,9,9} -> 2(Root[9,2]+9) and trivial variations
{3,7,8,10} -> 7 Root[8,3] +10 and trivial variations
{3,4,9,10} -> 4+Log[3,9]*10 and trivial variations
{7, 8, 9, 9} -> 8 Root[9,9-7] and trivial variations, and
{8, 8, 9, 10} -> 8 Root[9,10-8] and trivial variations.

The hands that remain unsolvable are

{{1, 1, 1, 1}, {1, 1, 1, 2}, {1, 1, 1, 3}, {1, 1, 1, 4}, {1, 1, 1, 6}, {1, 1, 1, 7}, {1, 1, 1, 9}, {1, 1, 1, 10}, {1, 1, 2, 2}, {1, 1, 2, 3}, {1, 1, 5, 9}, {1, 1, 5, 10}, {1, 1, 6, 7}, {1, 1, 6, 10}, {1, 1, 7, 7}, {1, 1, 7, 8}, {1, 1, 7, 9}, {1, 1, 8, 10}, {1, 1, 9, 9}, {1, 1, 9, 10}, {1, 1, 10, 10}, {1, 2, 2, 2}, {1, 2, 9, 10}, {1, 2, 10, 10}, {1, 4, 9, 9}, {1, 5, 7, 7}, {1, 6, 6, 7}, {1, 6, 7, 7}, {1, 6, 7, 8}, {1, 6, 10, 10}, {1, 7, 7, 7}, {1, 7, 7, 8}, {1, 7, 10, 10}, {1, 8, 9, 9}, {1, 8, 9, 10}, {1, 8, 10, 10}, {1, 9, 9, 9}, {1, 9, 9, 10}, {1, 9, 10, 10}, {1, 10, 10, 10}, {2, 2, 2, 2}, {2, 2, 7, 9}, {2, 6, 7, 7}, {2, 7, 7, 7}, {2, 7, 7, 9}, {2, 7, 8, 10}, {2, 7, 9, 9}, {2, 9, 9, 9}, {2, 9, 9, 10}, {2, 10, 10, 10}, {3, 3, 4, 10}, {3, 3, 10, 10}, {3, 4, 6, 7}, {3, 5, 5, 10}, {3, 5, 7, 7}, {3, 5, 8, 10}, {3, 10, 10, 10}, {4, 4, 5, 9}, {4, 4, 6, 6}, {4, 4, 6, 7}, {4, 4, 9, 9}, {4, 4, 9, 10}, {4, 7, 7, 9}, {4, 7, 7, 10}, {4, 9, 9, 9}, {4, 9, 10, 10}, {4, 10, 10, 10}, {5, 5, 5, 7}, {5, 5, 5, 8}, {5, 5, 5, 10}, {5, 5, 6, 9}, {5, 5, 6, 10}, {5, 5, 7, 9}, {5, 6, 7, 10}, {5, 7, 7, 7}, {5, 7, 7, 8}, {5, 7, 9, 9}, {5, 8, 9, 9}, {5, 8, 10, 10}, {5, 9, 9, 9}, {5, 9, 9, 10}, {5, 10, 10, 10}, {6, 6, 6, 7}, {6, 6, 7, 7}, {6, 6, 7, 8}, {6, 6, 10, 10}, {6, 7, 7, 7}, {6, 7, 7, 8}, {6, 7, 7, 9}, {6, 7, 8, 8}, {6, 8, 10, 10}, {6, 9, 9, 9}, {6, 9, 10, 10}, {7, 7, 7, 7}, {7, 7, 7, 8}, {7, 7, 7, 9}, {7, 7, 7, 10}, {7, 7, 8, 8}, {7, 7, 8, 9}, {7, 7, 8, 10}, {7, 7, 9, 9}, {7, 7, 10, 10}, {7, 8, 8, 8}, {7, 9, 9, 9}, {7, 9, 9, 10}, {7, 9, 10, 10}, {7, 10, 10, 10}, {8, 8, 8, 8}, {8, 8, 8, 9}, {8, 8, 9, 9}, {8, 8, 10, 10}, {8, 9, 9, 9}, {8, 9, 9, 10}, {8, 9, 10, 10}, {8, 10, 10, 10}, {9, 9, 9, 9}, {9, 9, 9, 10}, {9, 9, 10, 10}, {9, 10, 10, 10}, {10, 10, 10, 10}}.

# Solving 24s, part i: Algebraic programming, arithmetic allowed

If the game of 24s is played with binary operators only, there is a finite number of different possible ways to combine the cards. Given a modern computer, it is perfectly solvable. The basic technique that I use is called algebraic programming, and amounts to combining every possible combination of four cards and every one of the permitted operators in every possible way, then selecting the combinations that equal 24.

This can be done in any programming language, but it’s natural in Mathematica, which natively supports the set operations on which this method relies.

First, some observations:

1. We have four cards, each of which can be any number from 1 to 10. We therefore have 10*10*10*10 (10,000) possible hands, if order matters.

2. If order doesn’t matter, such that {1,2,3,4} is the same as {4,3,2,1}, there are only 715 possible combinations

`In[]:= Length[Union[Sort /@ Tuples[Range[10], 4]]]`
`Out[]= 715`

Now we develop our combinations. This can be made easier using Andrzej Kozlowski’s “ReplaceAllList” function from The Mathematica Journal 9:2 © 2004.

```ReplaceAllList[expr_, rules_] := Module[{i}, Join[ReplaceList[expr, rules], If[AtomQ[expr], {}, Join @@ Table[ ReplacePart[expr, #, i] & /@ ReplaceAllList[expr[[i]], rules], {i, Length[expr]}]]]]```

We have a choice — make our function set commutative, so that {3,2} is processed as both 3-2 and 2-3, or make our card set comprehensive, so that both arrangements are passed through the function. I elected the latter, but the former should work equally well.

Start by finding all the ways of associating four elements.

```ClearAll[f]; SetAttributes[f, {Flat, OneIdentity}]; rawFunctions = Union[FixedPoint[Union[Flatten[ReplaceAllList[#, f[a_, b_] -> g[a, b]]]] &, f[a, b, c, d]] /. f -> g];```

```Off[General::"spell1"]; Off[General::"spell"]; divide[x_, y_] /; y != 0 := Divide[x, y]; divide[x_, 0] := Indeterminate;```

Then we remove all duplicates and expressions that involve the application of g to three elements.

```uniqueFunctions = DeleteCases[rawFunctions, _?(Not[FreeQ[#, g[x__ /; Length[{x}] >= 3]]] &), 1];```

Finally we replace g by Subscript[A, 2],Subscript[A, 1],Subscript[A, 0], in this order, and swap in the numbers from a hand of cards

```functionsWNumbers[hands_List] := Map[(i = 0; MapAll[If[# === g, # /. g -> Subscript[A, Mod[++i, 3]], #] &, uniqueFunctions, Heads -> True] /. {a -> #[[1]], b -> #[[2]], c -> #[[3]], d -> #[[4]]}) &, hands]```

The following step generates every possible combination of operators. For four binary functions and four cards, we have a maximum of three functions per hand and only 64 possible combinations.

```generateRules[binaryFunctions_List, numCards_Integer] := Module[{raw, refined, numFuncs}, numFuncs = Length[binaryFunctions]; raw = Map[Thread, Map[RuleDelayed[Array[Subscript[A, # - 1] &, {numFuncs}], #] &, Distribute[Array[binaryFunctions &, {numFuncs}], List]]];```
(* since an actual hand never involves more than three binary operations,
we remove the rules involving unnecessary As.*)

``` refined = Union[DeleteCases[raw,Apply[Alternatives, Map[HoldPattern[#] &, Table[Subscript[A, i] :> _, {i, numCards - 1, numFuncs - 1}]]], Infinity]]; refined]```

Now we map our selected functions over the generic rules from the previous step.

```generateHands[functions_List, rules_List] := Table[Union[# /. rules] & /@ functions[[i]], {i, 1, Length[functions]}]```

When we get our answers, {1,1,2,2} is treated as distinct from {2,2,1,1}. Let’s fix that. The following assumes the cardSet is a single list of four integers {1,1,2,3}, and that the possibilitySet is a list of {{ordered four cards},{solutions}} like
{{6,6,6,6},{((6+6)+6)+6,(6+(6+6))+6,(6+6)+(6+6),6+((6+6)+6),6+(6+(6+6)),6 6-(6+6),(6 6-6)-6}}

```solutionsForSet[cardSet_List, possibilitySet_List] := Module[{allVarieties, matches}, allVarieties = Permutations[cardSet]; matches = Select[possibilitySet, MemberQ[allVarieties, #[[1]]] &]; Flatten[matches[[All, 2]], 1]]```

So, what do we find? Running every possible hand of cards through our 64 possible rules, and seeing which come out equal to 24, we find 566 of the 715 possible hands (about 79% of all possible cases) are solvable with arithmetic alone.

The unsolvable hands are {{1, 1, 1, 1}, {1, 1, 1, 2}, {1, 1, 1, 3}, {1, 1, 1, 4}, {1, 1, 1, 5}, {1, 1, 1, 6}, {1, 1, 1, 7}, {1, 1, 1, 9}, {1, 1, 1, 10}, {1, 1, 2, 2}, {1, 1, 2, 3}, {1, 1, 2, 4}, {1, 1, 2, 5}, {1, 1, 3, 3}, {1, 1, 5, 9}, {1, 1, 5, 10}, {1, 1, 6, 7}, {1, 1, 6, 10}, {1, 1, 7, 7}, {1, 1, 7, 8}, {1, 1, 7, 9}, {1, 1, 8, 9}, {1, 1, 8, 10}, {1, 1, 9, 9}, {1, 1, 9, 10}, {1, 1, 10, 10}, {1, 2, 2, 2}, {1, 2, 2, 3}, {1, 2, 9, 9}, {1, 2, 9, 10}, {1, 2, 10, 10}, {1, 3, 5, 5}, {1, 4, 7, 10}, {1, 4, 8, 10}, {1, 4, 9, 9}, {1, 5, 5, 7}, {1, 5, 5, 8}, {1, 5, 7, 7}, {1, 6, 6, 7}, {1, 6, 7, 7}, {1, 6, 7, 8}, {1, 6, 10, 10}, {1, 7, 7, 7}, {1, 7, 7, 8}, {1, 7, 10, 10}, {1, 8, 9, 9}, {1, 8, 9, 10}, {1, 8, 10, 10}, {1, 9, 9, 9}, {1, 9, 9, 10}, {1, 9, 10, 10}, {1, 10, 10, 10}, {2, 2, 2, 2}, {2, 2, 2, 6}, {2, 2, 7, 9}, {2, 2, 9, 9}, {2, 3, 3, 4}, {2, 5, 5, 5}, {2, 5, 5, 6}, {2, 5, 9, 9}, {2, 6, 7, 7}, {2, 7, 7, 7}, {2, 7, 7, 9}, {2, 7, 8, 10}, {2, 7, 9, 9}, {2, 9, 9, 9}, {2, 9, 9, 10}, {2, 10, 10, 10}, {3, 3, 4, 10}, {3, 3, 5, 8}, {3, 3, 7, 10}, {3, 3, 10, 10}, {3, 4, 6, 7}, {3, 4, 8, 8}, {3, 4, 9, 10}, {3, 5, 5, 5}, {3, 5, 5, 10}, {3, 5, 7, 7}, {3, 5, 8, 10}, {3, 7, 8, 10}, {3, 10, 10, 10}, {4, 4, 5, 9}, {4, 4, 6, 6}, {4, 4, 6, 7}, {4, 4, 9, 9}, {4, 4, 9, 10}, {4, 7, 7, 9}, {4, 7, 7, 10}, {4, 9, 9, 9}, {4, 9, 10, 10}, {4, 10, 10, 10}, {5, 5, 5, 7}, {5, 5, 5, 8}, {5, 5, 5, 10}, {5, 5, 6, 9}, {5, 5,
6, 10}, {5, 5, 7, 9}, {5, 6, 7, 10}, {5, 7, 7, 7}, {5, 7, 7, 8}, {5, 7, 9, 9}, {5, 8, 9, 9}, {5, 8, 9, 10}, {5, 8, 10, 10}, {5, 9, 9, 9}, {5, 9, 9, 10}, {5, 10, 10, 10}, {6, 6, 6, 7}, {6, 6, 7, 7}, {6, 6, 7, 8}, {6, 6, 9, 9}, {6, 6, 10, 10}, {6, 7, 7, 7}, {6, 7, 7, 8}, {6, 7, 7, 9}, {6, 7, 8, 8}, {6, 7, 9, 10}, {6, 8, 10, 10}, {6, 9, 9, 9}, {6, 9, 10, 10}, {7, 7, 7, 7}, {7, 7, 7, 8}, {7, 7, 7, 9}, {7, 7, 7, 10}, {7, 7, 8, 8}, {7, 7, 8, 9}, {7, 7, 8, 10}, {7, 7, 9, 9}, {7, 7, 10, 10}, {7, 8, 8, 8}, {7, 8, 9, 9}, {7, 9, 9, 9}, {7, 9, 9, 10}, {7, 9, 10, 10}, {7, 10, 10, 10}, {8, 8, 8, 8}, {8, 8, 8, 9}, {8, 8, 9, 9}, {8, 8, 9, 10}, {8, 8, 10, 10}, {8, 9, 9, 9}, {8, 9, 9, 10}, {8, 9, 10, 10}, {8, 10, 10, 10}, {9, 9, 9, 9}, {9, 9, 9, 10}, {9, 9, 10, 10}, {9, 10, 10, 10}, {10, 10, 10, 10}}

These same methods can be used with larger number of functions too, as I will show in coming posts.