We met each other during this airtable contest. We shared some ideas for airtable blocks, and we came up with 'distance grouping'. As a member of the national volleyball league in Belgium, Pascal has to organise the competition for all youth teams. In Belgium only, parents drive +5.000.000 miles per season with their children to the volleyball games.
Please watch our pitch-video: https://www.youtube.com/watch?v=aw8hQ_wRqf0
Demo video: https://www.youtube.com/watch?v=Aen_t8UmrLk
What it does
- Block 1 (Distance Matrix): Gets the distances between all locations
- Block 2 (Distance Grouping): Divides locations into groups based on minimizing distance
Use case: Our airtable block can be used to organise the series within a Volleyball League. The block generates evenly spread groups in the most efficient way regarding total amount of miles between the teams in the group. It can be used in any team-competition like basketball, soccer, hockey, ...
How we built it
First version: a single block that used the Google Maps API to map the locations, calculate the distances between the locations (distance matrix), group the locations based on distance, and then display the groups in a map.
Second version: break out the functionality of the first block into four separate blocks. For mapping and geocoding the locations, we defer to Airtable's Map block (rather than build our own). For calculating distances between locations, we use our custom block Distance Matrix. For finding the optimal grouping, we use our custom block Distance Grouping (which gets data from Distance Matrix block). To visualize the grouping, we defer again to Airtable's Map block.
Challenges we ran into
- Google Distance Matrix API has limits that make using it a bit more complicated
- Saving the matrix is also complicated. We could make the user create a new table to save the data, but because it's a hackathon, we decided to see if we could save the data in block and pipe it over to the other block. Unfortunately, we ran into limits when trying to save large matrices into the block's own storage (i.e., globalConfig).
- Combinatorics! It's not factorial but the solution we have currently doesn't scale. The current solution simply generates all of the combinations, scores them, and picks the one with the best score. For 16 locations divided into 4 groups, that's (16 choose 4) * (12 choose 3) * (8 choose 2) * (4 choose 1) = 44,844,800. So, for 16 locations, the code has to score 45 million combinations and then iterate through to find the best score.
Accomplishments that we're proud of
- We innovate for a better world
- We found a challenge that is hard to solve. (at this moment, a few hours before submission we are still searching for a solution in distance grouping, for a number of teams>10).
- We made it work to communicate between 2 blocks
What we learned
- We can build things together as a team, even if you live on other side of the world.
- Combinatorics are hard.
- Blocks can talk to each other, if you try.
What's next for Distance Grouping
Watch out our pitch-video (https://www.youtube.com/watch?v=aw8hQ_wRqf0) to check future opportunities. We like to continue work on this.
Possible next stops for code:
- Make the Distance Matrix block more generic, expose more of the Google Distance Matrix API features through the UI.
- Generalize and abstract (make reusable) the code that allows blocks to communicate with each other.
Log in or sign up for Devpost to join the conversation.