This doc is based on Caesar_Sengupta’s , where he wants to generate a set of 1:1 meeting matchups within a list of people. Start with a list of names Shuffle the list, so that we can randomly choose a 1:1 meeting partner for each person People can’t meet with themselves Everyone needs to be included, and no doubles (a fully random selection of people, calculated each row, would sometimes result in certain names appearing multiple times, and certain names not appearing at all) We want to pull random pairs of names out of a hat until there are no more pairs left Assign new random numbers to each Person each time a button is pressed (I made a to get around of the native Random() function) Clear out the old Matchups, if any Sort the list by the random number column Grab pairs of people, and set them as each other’s match in the matchup column
There are no rows in this table
Comments ( // bla bla bla ) don’t work in Coda, but I’m including them here to try to explain things. If you want to copy-paste the code, it might be better to right-click on the button. // Loop through the People table, working on each row one at a time // Generate a random number for the random number column CurrentValue, // CurrentValue means the current Person in the People table // For the seed, we're using the last modified date of the row, so that // we get a fresh result each time we press the button; and also the ID // of the row, so that we get a unique result for each row Randomizer::RandomFromSeed( CurrentValue.[Last Modified].ToNumber() + CurrentValue.RowId() // Clear out any old matchups from last time we pressed the button // Now that there are random numbers there, loop through the table in random order People.Sort(true, People.[Random Number]), SortedPeople, // Every time we say SortedPeople, we mean the randomly-sorted table Sequence(1,SortedPeople.Count()).FormulaMap( // We're pulling names from the hat in pairs; so on odd pulls (e.g. 1st or // 5th pull), we'll pair them with the next pull (2nd or 6th). That means on // even pulls (2nd or 6th), we'll pair them with the previous pull (1st or 5th) // CurrentValue is the number of times we've been through this loop (our pull#) // E.g. on our 6th pull, edit the row for the 6th Person SortedPeople.Nth(CurrentValue), // Edit its Matchup column // Set that Matchup column to the 5th Person (6 - 1) SortedPeople.Nth(CurrentValue-1) SortedPeople.Nth(CurrentValue), SortedPeople.Nth(CurrentValue+1)
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (