Skip to content
Gallery
Puzzle #10: Fruit combos
Share
Explore

icon picker
Solution

Total number of combinations:
24
ー Need
0
Ensure 24 rows -- No Rows Needed
Sizes
Size
Entries
Count
Count excluding self
1
Small
Grape
Strawberry
Peach
3
8
2
Medium
Mango
Apple
Banana
Kiwano
4
6
3
Large
Pineapple
Watermelon
2
12
There are no rows in this table
Unique Combinations
Small
Medium
Large
N
1
Grape
Apple
Watermelon
1
2
Grape
Apple
Pineapple
2
3
Grape
Banana
Watermelon
3
4
Grape
Banana
Pineapple
4
5
Grape
Kiwano
Watermelon
5
6
Grape
Kiwano
Pineapple
6
7
Grape
Mango
Watermelon
7
8
Grape
Mango
Pineapple
8
9
Strawberry
Apple
Watermelon
9
10
Strawberry
Apple
Pineapple
10
11
Strawberry
Banana
Watermelon
11
12
Strawberry
Banana
Pineapple
12
13
Strawberry
Kiwano
Watermelon
13
14
Strawberry
Kiwano
Pineapple
14
15
Strawberry
Mango
Watermelon
15
16
Strawberry
Mango
Pineapple
16
17
Peach
Apple
Watermelon
17
18
Peach
Apple
Pineapple
18
19
Peach
Banana
Watermelon
19
20
Peach
Banana
Pineapple
20
21
Peach
Kiwano
Watermelon
21
22
Peach
Kiwano
Pineapple
22
23
Peach
Mango
Watermelon
23
24
Peach
Mango
Pineapple
24
There are no rows in this table

Solution Detail

Key idea: f(RowNumber) → Unique Combination

What a fun challenge!
There are lots of ways to solve this problem. We brainstormed a few:
Write a network of buttons - e.g. iterate through each group of fruits (small, medium, large) and add them each to a table in a certain order to generate all the combinations
Map to a number - e.g. if there are two options for each size, then you could translate a binary number like 001, 010, 011, ...
Use a recursive formula - where each formula iterates through each size with a base case when there are no more values to be added
Calculate it algorithmically from a row number - i.e. ensure there are N rows (# of small fruits * # of medium fruits * # of large fruits), and use each row's row number to describe each unique combination.

This solution mostly builds on the last idea.

Step 1: Calculate the number of rows we need, and ensure they exist

This is the first line of the solution:
Loading…
These are the formulas:
This is then hooked up to an automation that will push the button whenever the Fruits Table changes.

Step 2: Given a Row Number, generate a unique combination

Before getting to the math part, we have to deal with the fact that RowID() is a great formula, but it is monotonically increasing - so if you delete rows, you will have gaps. So you'll notice that the table has a column called N which gives a ordinal number to each row with no gaps:
Next we need to generate the unique combination for each value of N. The basic idea is to do it numerically first (with columns i, j, and k) and then use those as indexes to pick the i-th, j-th, and k-th fruits from each of the small, medium, and large sets. So for the math-y parts, here's how i, j, and k are calculated.
After that, the Small, Medium, and Large columns are simple indexed lookups
One quick sidenote that you might have noticed is that you can get a particular "cell value" from a cell by typing @rowname.columnname. This can be handy for lookup values like @Small.Count

Putting it all together

Here's the same view with the underlying columns unhidden
View of Unique Combinations
Small
Medium
Large
N
i
j
k
Row ID
1
Grape
Apple
Watermelon
1
1
2
2
1
2
Grape
Apple
Pineapple
2
1
2
1
2
3
Grape
Banana
Watermelon
3
1
3
2
3
4
Grape
Banana
Pineapple
4
1
3
1
4
5
Grape
Kiwano
Watermelon
5
1
4
2
5
6
Grape
Kiwano
Pineapple
6
1
4
1
6
7
Grape
Mango
Watermelon
7
1
1
2
7
8
Grape
Mango
Pineapple
8
1
1
1
8
9
Strawberry
Apple
Watermelon
9
2
2
2
9
10
Strawberry
Apple
Pineapple
10
2
2
1
10
11
Strawberry
Banana
Watermelon
11
2
3
2
11
12
Strawberry
Banana
Pineapple
12
2
3
1
12
13
Strawberry
Kiwano
Watermelon
13
2
4
2
13
14
Strawberry
Kiwano
Pineapple
14
2
4
1
14
15
Strawberry
Mango
Watermelon
15
2
1
2
15
16
Strawberry
Mango
Pineapple
16
2
1
1
16
17
Peach
Apple
Watermelon
17
3
2
2
17
18
Peach
Apple
Pineapple
18
3
2
1
18
19
Peach
Banana
Watermelon
19
3
3
2
19
20
Peach
Banana
Pineapple
20
3
3
1
20
21
Peach
Kiwano
Watermelon
21
3
4
2
21
22
Peach
Kiwano
Pineapple
22
3
4
1
22
23
Peach
Mango
Watermelon
23
3
1
2
23
24
Peach
Mango
Pineapple
24
3
1
1
24
There are no rows in this table



Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.