No duplicates in Random

Hey guys

This is probably asked a lot and Ive found some topics on this already but I don't quite understand it yet
I've made a snippet with 2 random lists
Those also will be used 2 times in a sentence. So like this:

{list=["Nice", "Smooth", "Amazing", "Love the", "Sweet", "Big", "Beautiful", "Great", "Fire", "Dope"]; trim=yes}{list2=["sound", "vibe", "chords", "melody", "creativity", "mixdown", "quality"]}
{=list[ceil(random() * count(list))]} {=list2[ceil(random() * count(list2))]} and{key: space}
{list=["Nice", "Smooth", "Amazing", "Love the", "Sweet", "Big", "Beautiful", "Great", "Fire", "Dope"]; trim=yes}{list2=["sound", "vibe", "chords", "melody", "creativity", "mixdown", "quality"]}
{=list[ceil(random() * count(list))]} {=list2[ceil(random() * count(list2))]}

I want no duplicates in the list. Im not great coder so I have no idea how to even start. Is there a simple way for me to implement this?
Im planning to use the random list a lot so I want to learn how to get better at it.

Thanks!

Have you considered using our randomize command pack? It does essentially the same thing in that you set a menu of options and it will randomly give you one of them when you use the snippet.

You could use this command pack to create both lists and just make sure there are no duplicates in the menus and it would work fine, plus it's easier to use :slight_smile:

Hey! I did a quick edit to make it possible.
I created a duplicate list, where the word chosen from the first list is replaced by what originally was the last word in your list. Did this for both original lists :slight_smile:

{=fixlist1} {=fixlist11}
{=fixlist2} {=fixlist22}
{list=["Nice", "Smooth", "Amazing", "Love the", "Sweet", "Big", "Beautiful", "Great", "Fire"]; trim=yes}{list2=["sound", "vibe", "chords", "melody", "creativity", "mixdown"]}
{list3=map(list, (x) -> replaceregex(x, fixlist1, "Dope")); trim=yes}{list4=map(list2, (x) -> replaceregex(x, fixlist11, "quality")); trim=yes}
{fixlist1=list[ceil(random() * count(list))]} {fixlist11=list2[ceil(random() * count(list2))]}
{fixlist2=list3[ceil(random() * count(list))]} {fixlist22=list4[ceil(random() * count(list4))]; trim=yes}

3 Likes

Benjamin you are amazing! Thanks for taking your time to fix my snippet and help me. Dylan also thanks a lot for the recommendation. WIll definitely try it out.

2 Likes

Hey Dylan!

Tried the randomizer tool and it's actually so easy indeed. This will be my go-to method for me now! Thanks a ton

1 Like

Glad to hear that :slight_smile: