Choose a random coordinate from a list

Edit: I figured most of it out! Here’s the slide so far - Choose Random Points • Activity Builder by Desmos

Only thing I can’t figure out is if I can choose the 5 random points and prevent getting any repeats.
Thanks for any help.

Original Post:
I’m trying to find a way to generate and display a list of 5 random coordinate points, but the tricky part (for me at least) is that those points have to come from a list of available coordinates (can’t just be randomly choosing an x-coord and randomly choosing a y-coord from two lists). For example: pretend there are 20 specific points to choose from, and when you press a button, 5 of those 20 points will randomly be generated (without repeats) and displayed in a table.

That would be the dream. Not sure how to make it come true. I haven’t started anything because I don’t know where to start. I currently have my available coordinates to choose from in two lists (one for the x and one for the y). Can I choose a random value from the x-list, and match it with the corresponding position in the y-list to finish the coordinate? And how would I do that 5 times and ensure no repeats? And then get them to autofill into a table.

Thanks for any help.

You can do the randomization within the graph, which will make it easier to accomplish what you want. You can use the .random(n,seed) function to pull a random number of elements from a list without duplication. Changing the seed will re-randomize. So instead of using CL to randomize, you just set the seed to the button’s presscount value, so changing the presscount re-randomizes. Combine this with the fact that P = (A1,B1) generates a list of points. Here is an example in slide 2: [Copy of] Choose Random Points • Activity Builder by Desmos

1 Like

Thanks so much! I knew there had to be an “easy” way to code this.

Ignore the last edit if you saw it, I figured out there are a few repeated points in the original list, so your solution works great. Thanks again!

No problem. You can also use the unique function like unique(P).random(5,seed). That will return a copy of the list with duplicates removed.