Skip to main content
5 of 7
added 8 characters in body
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C++ (gcc), 197 \$\cdots\$ 184 182 bytes

#import<regex>
using V=std::vector<int>;void f(V&v){V i=v,r=v;int y=0,n,j;for(int&a:i)a=y++;std::random_shuffle(&i[0],&*end(i));for(j=n=rand()%v.size()+1;j;)r[i[--j]]=v[i[j%n]];v=r;}

Try it online!

Added 2 bytes to fix an error.
Saved 3 5 bytes thanks to ceilingcat!!!

Inputs a vector of integers.
Randomly shuffles a random subgroup of the elements in place.

Noodle9
  • 20.3k
  • 3
  • 21
  • 46