Attempting to get item 10 of a list of length 9 error

As far as I can see, the problem seems to be how you are creating the list assignedNumbers... in rare cases, 40 times trying to add a number between 1 and 10 to the list which still does not exist in the list will fail... in the example list from the error message, the number 9 is missing...

There are easier ways to shuffle a list, I think, the listUtils extension offers a method for that..

Taifun